Update app.py
Browse files
app.py
CHANGED
|
@@ -45,16 +45,16 @@ def load_models():
|
|
| 45 |
|
| 46 |
# Audio models
|
| 47 |
audio_models = {}
|
| 48 |
-
for p, repo, f in [
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
]:
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
|
| 57 |
-
path_c = hf_hub_download(repo_id="ericjedha/pilier_c", filename="
|
| 58 |
model_c = ASTForAudioClassification.from_pretrained("MIT/ast-finetuned-audioset-10-10-0.4593", num_labels=len(CATEGORIES), ignore_mismatched_sizes=True)
|
| 59 |
sd = torch.load(path_c, map_location=DEVICE)['model_state_dict']
|
| 60 |
model_c.load_state_dict({k.replace('ast.', ''): v for k, v in sd.items()}, strict=False)
|
|
|
|
| 45 |
|
| 46 |
# Audio models
|
| 47 |
audio_models = {}
|
| 48 |
+
for p, repo, f in [
|
| 49 |
+
('A', 'ericjedha/pilier_a', 'best_pilier_a_e29_f1_0.9005.pth'),
|
| 50 |
+
('B', 'ericjedha/pilier_b', 'best_pilier_b_f1_0.9103.pth')
|
| 51 |
+
]:
|
| 52 |
+
path = hf_hub_download(repo_id=repo, filename=f)
|
| 53 |
+
m = timm.create_model("vit_small_patch16_224", num_classes=len(CATEGORIES), in_chans=3)
|
| 54 |
+
m.load_state_dict(torch.load(path, map_location=DEVICE)['model_state_dict'])
|
| 55 |
+
audio_models[p] = m.to(DEVICE).eval()
|
| 56 |
|
| 57 |
+
path_c = hf_hub_download(repo_id="ericjedha/pilier_c", filename="best_pilier_c_ast_v95_2_f1_0.9109.pth")
|
| 58 |
model_c = ASTForAudioClassification.from_pretrained("MIT/ast-finetuned-audioset-10-10-0.4593", num_labels=len(CATEGORIES), ignore_mismatched_sizes=True)
|
| 59 |
sd = torch.load(path_c, map_location=DEVICE)['model_state_dict']
|
| 60 |
model_c.load_state_dict({k.replace('ast.', ''): v for k, v in sd.items()}, strict=False)
|