Upload model.py with huggingface_hub
Browse files
model.py
CHANGED
|
@@ -63,10 +63,12 @@ def load_classification_model(provider: str = "google", device: str = "cpu"):
|
|
| 63 |
assert provider in ("google", "ign"), "provider must be 'google' or 'ign'"
|
| 64 |
|
| 65 |
path = hf_hub_download(REPO, f"inception_{provider}_best.pth")
|
| 66 |
-
model = inception_v3(weights=None, aux_logits=
|
| 67 |
-
model.fc
|
|
|
|
| 68 |
|
| 69 |
state = torch.load(path, map_location=device, weights_only=False)
|
| 70 |
model.load_state_dict(state)
|
|
|
|
| 71 |
|
| 72 |
return model.eval().to(device)
|
|
|
|
| 63 |
assert provider in ("google", "ign"), "provider must be 'google' or 'ign'"
|
| 64 |
|
| 65 |
path = hf_hub_download(REPO, f"inception_{provider}_best.pth")
|
| 66 |
+
model = inception_v3(weights=None, aux_logits=True)
|
| 67 |
+
model.fc = nn.Linear(model.fc.in_features, 1)
|
| 68 |
+
model.AuxLogits.fc = nn.Linear(model.AuxLogits.fc.in_features, 1)
|
| 69 |
|
| 70 |
state = torch.load(path, map_location=device, weights_only=False)
|
| 71 |
model.load_state_dict(state)
|
| 72 |
+
model.aux_logits = False # désactive pour l'inférence
|
| 73 |
|
| 74 |
return model.eval().to(device)
|