timm feat dim dry-run fix
Browse files- job_train.py +5 -1
job_train.py
CHANGED
|
@@ -61,10 +61,14 @@ def build_backbone(arch: str, pretrained: bool):
|
|
| 61 |
names = {"efficientnet_lite0": ["tf_efficientnet_lite0", "efficientnet_lite0"],
|
| 62 |
"ghostnet_050": ["ghostnet_050", "ghostnet_100"]}[arch]
|
| 63 |
last = None
|
|
|
|
| 64 |
for n in names:
|
| 65 |
try:
|
| 66 |
m = timm.create_model(n, pretrained=pretrained, num_classes=0)
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
| 68 |
except Exception as e:
|
| 69 |
last = e
|
| 70 |
raise RuntimeError(f"timm model for {arch} failed: {last}")
|
|
|
|
| 61 |
names = {"efficientnet_lite0": ["tf_efficientnet_lite0", "efficientnet_lite0"],
|
| 62 |
"ghostnet_050": ["ghostnet_050", "ghostnet_100"]}[arch]
|
| 63 |
last = None
|
| 64 |
+
import torch
|
| 65 |
for n in names:
|
| 66 |
try:
|
| 67 |
m = timm.create_model(n, pretrained=pretrained, num_classes=0)
|
| 68 |
+
m.eval()
|
| 69 |
+
with torch.no_grad():
|
| 70 |
+
feat = int(m(torch.zeros(1, 3, 224, 224)).shape[1])
|
| 71 |
+
return m, feat
|
| 72 |
except Exception as e:
|
| 73 |
last = e
|
| 74 |
raise RuntimeError(f"timm model for {arch} failed: {last}")
|