Update app.py
Browse files
app.py
CHANGED
@@ -30,8 +30,16 @@ class NewheadDinov2ForImageClassification(Dinov2ForImageClassification):
|
|
30 |
|
31 |
# Classifier head
|
32 |
self.classifier = create_head(config.hidden_size * 2, config.num_labels)
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
# import labels
|
36 |
classes_names = ["Acropore_branched", "Acropore_digitised", "Acropore_tabular", "Algae_assembly",
|
37 |
"Algae_limestone", "Algae_sodding", "Dead_coral", "Fish", "Human_object",
|
@@ -43,8 +51,7 @@ classes_names = ["Acropore_branched", "Acropore_digitised", "Acropore_tabular",
|
|
43 |
classes_nb = list(np.arange(len(classes_names)))
|
44 |
id2label = {int(classes_nb[i]): classes_names[i] for i in range(len(classes_nb))}
|
45 |
label2id = {v: k for k, v in id2label.items()}
|
46 |
-
|
47 |
-
model = NewheadDinov2ForImageClassification.from_pretrained(checkpoint_name)
|
48 |
|
49 |
def sigmoid(_outputs):
|
50 |
return 1.0 / (1.0 + np.exp(-_outputs))
|
|
|
30 |
|
31 |
# Classifier head
|
32 |
self.classifier = create_head(config.hidden_size * 2, config.num_labels)
|
33 |
+
|
34 |
+
model = NewheadDinov2ForImageClassification.from_pretrained(checkpoint_name)
|
35 |
+
|
36 |
+
# IMPORT MODEL CONFIG PARAMETERS
|
37 |
+
hf_hub_download(repo_id=checkpoint_name, filename="config.json")
|
38 |
+
id2label = config["id2label"]
|
39 |
+
label2id = config["label2id"]
|
40 |
+
image_size = config["image_size"]
|
41 |
+
classes_names = list(label2id.keys())
|
42 |
+
'''
|
43 |
# import labels
|
44 |
classes_names = ["Acropore_branched", "Acropore_digitised", "Acropore_tabular", "Algae_assembly",
|
45 |
"Algae_limestone", "Algae_sodding", "Dead_coral", "Fish", "Human_object",
|
|
|
51 |
classes_nb = list(np.arange(len(classes_names)))
|
52 |
id2label = {int(classes_nb[i]): classes_names[i] for i in range(len(classes_nb))}
|
53 |
label2id = {v: k for k, v in id2label.items()}
|
54 |
+
'''
|
|
|
55 |
|
56 |
def sigmoid(_outputs):
|
57 |
return 1.0 / (1.0 + np.exp(-_outputs))
|