Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,26 @@
|
|
1 |
-
import torch
|
2 |
-
import torch.nn as nn
|
3 |
from config import MLP
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
model
|
8 |
-
|
9 |
-
model.eval()
|
10 |
|
11 |
-
#
|
12 |
-
|
13 |
-
with torch.no_grad():
|
14 |
-
inputs = torch.tensor(inputs).float().unsqueeze(0) # Add batch dimension
|
15 |
-
output = model(inputs)
|
16 |
-
if isinstance(output, torch.Tensor):
|
17 |
-
return output.squeeze().tolist()
|
18 |
-
return output # fallback
|
19 |
|
20 |
-
#
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
)
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
# Launch
|
29 |
if __name__ == "__main__":
|
30 |
-
|
|
|
|
|
|
|
1 |
from config import MLP
|
2 |
+
from mmcv import Config
|
3 |
+
from mmdet.models import build_detector
|
4 |
+
import torch
|
5 |
|
6 |
+
def main():
|
7 |
+
# Print model type from config
|
8 |
+
print(f"Model type: {MLP['type']}")
|
|
|
9 |
|
10 |
+
# Build the model from the config dict
|
11 |
+
model = build_detector(MLP, train_cfg=MLP.get('train_cfg'), test_cfg=MLP.get('test_cfg'))
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
# Set model to evaluation mode
|
14 |
+
model.eval()
|
15 |
+
|
16 |
+
# Print model architecture summary
|
17 |
+
print(model)
|
18 |
+
|
19 |
+
# Optional: dummy input test (batch of 1 image with 3 channels, 800x1333)
|
20 |
+
dummy_input = torch.randn(1, 3, 800, 1333)
|
21 |
+
with torch.no_grad():
|
22 |
+
result = model.forward_dummy(dummy_input)
|
23 |
+
print("Forward pass output:", result)
|
24 |
|
|
|
25 |
if __name__ == "__main__":
|
26 |
+
main()
|