Tan Zi Xu commited on
Commit ·
04aad2f
1
Parent(s): 28e611c
patching convnext model
Browse files- infer.py +5 -1
- models/convNext_tiny_v1/model_config.json +1 -1
- models/manifest.json +10 -2
infer.py
CHANGED
|
@@ -32,7 +32,11 @@ def _get_feature_dim(model, arch: str) -> int:
|
|
| 32 |
|
| 33 |
def _attach_head(model, arch: str, head: nn.Module) -> nn.Module:
|
| 34 |
if arch.startswith("resnet"): model.fc = head
|
| 35 |
-
elif arch.startswith("convnext"):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
elif arch.startswith("efficientnet_v2"): model.classifier = nn.Sequential(nn.Dropout(p=0.0), head)
|
| 37 |
elif arch.startswith("mobilenet_v3"): model.classifier = head
|
| 38 |
else: raise ValueError(f"Unsupported arch: {arch}")
|
|
|
|
| 32 |
|
| 33 |
def _attach_head(model, arch: str, head: nn.Module) -> nn.Module:
|
| 34 |
if arch.startswith("resnet"): model.fc = head
|
| 35 |
+
elif arch.startswith("convnext"):
|
| 36 |
+
ln = model.classifier[0] # LayerNorm
|
| 37 |
+
flat = model.classifier[1] # Flatten(1)
|
| 38 |
+
model.classifier = nn.Sequential(ln, flat, head)
|
| 39 |
+
return model
|
| 40 |
elif arch.startswith("efficientnet_v2"): model.classifier = nn.Sequential(nn.Dropout(p=0.0), head)
|
| 41 |
elif arch.startswith("mobilenet_v3"): model.classifier = head
|
| 42 |
else: raise ValueError(f"Unsupported arch: {arch}")
|
models/convNext_tiny_v1/model_config.json
CHANGED
|
@@ -46,7 +46,7 @@
|
|
| 46 |
256
|
| 47 |
],
|
| 48 |
"head_dropout": 0.25,
|
| 49 |
-
"head_norm": "
|
| 50 |
},
|
| 51 |
"stage_A": {
|
| 52 |
"epochs": 5,
|
|
|
|
| 46 |
256
|
| 47 |
],
|
| 48 |
"head_dropout": 0.25,
|
| 49 |
+
"head_norm": "layernorm"
|
| 50 |
},
|
| 51 |
"stage_A": {
|
| 52 |
"epochs": 5,
|
models/manifest.json
CHANGED
|
@@ -1,4 +1,12 @@
|
|
| 1 |
{
|
| 2 |
-
"resnet50_v1": {
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"resnet50_v1": {
|
| 3 |
+
"_comment": "Using 20250930_193300__resnet50__exp02",
|
| 4 |
+
"repo_id": "AAI3001-P20/streetview-resnet50",
|
| 5 |
+
"filename": "best.pth"
|
| 6 |
+
},
|
| 7 |
+
"convNext_tiny_v1": {
|
| 8 |
+
"_comment": "Using 20251006_230926__convnext_tiny__exp02",
|
| 9 |
+
"repo_id": "AAI3001-P20/streetview-convnext-tiny",
|
| 10 |
+
"filename": "best.pth"
|
| 11 |
+
}
|
| 12 |
}
|