justinkay
commited on
Commit
·
8a229fe
1
Parent(s):
4ade5b6
Correct bioclipv2 results
Browse files- compute_accuracy.py +0 -1
- hf_zeroshot.py +8 -7
- iwildcam_demo.pt +2 -2
- models.txt +1 -1
- process_iwildcam_data.py +5 -5
compute_accuracy.py
CHANGED
|
@@ -14,7 +14,6 @@ SPECIES_MAP = OrderedDict([
|
|
| 14 |
(6, "Mountain Lion"), # puma concolor
|
| 15 |
(101, "Common Eland"), # tragelaphus oryx
|
| 16 |
(102, "Waterbuck"), # kobus ellipsiprymnus
|
| 17 |
-
(163, "African Wild Dog") # lycaon pictus
|
| 18 |
])
|
| 19 |
|
| 20 |
def load_ground_truth():
|
|
|
|
| 14 |
(6, "Mountain Lion"), # puma concolor
|
| 15 |
(101, "Common Eland"), # tragelaphus oryx
|
| 16 |
(102, "Waterbuck"), # kobus ellipsiprymnus
|
|
|
|
| 17 |
])
|
| 18 |
|
| 19 |
def load_ground_truth():
|
hf_zeroshot.py
CHANGED
|
@@ -46,6 +46,8 @@ DESCRIPTIVE_CLASS_NAMES = [
|
|
| 46 |
MODELS = [
|
| 47 |
"openai/clip-vit-large-patch14",
|
| 48 |
"google/siglip2-large-patch16-384",
|
|
|
|
|
|
|
| 49 |
"imageomics/bioclip",
|
| 50 |
"imageomics/bioclip-2",
|
| 51 |
"facebook/PE-Core-L14-336",
|
|
@@ -200,13 +202,11 @@ def run_openclip_inference(model_name, image_paths, class_names):
|
|
| 200 |
print(f"Error loading OpenCLIP model {model_name}: {e}")
|
| 201 |
return None
|
| 202 |
|
| 203 |
-
def run_siglip_inference(image_paths, class_names):
|
| 204 |
"""Run zero-shot inference using SigLIP with manual CLIP-style computation."""
|
| 205 |
-
print("Loading SigLIP model
|
| 206 |
try:
|
| 207 |
from transformers import AutoProcessor, AutoModel
|
| 208 |
-
|
| 209 |
-
model_name = "google/siglip2-so400m-patch16-naflex"
|
| 210 |
processor = AutoProcessor.from_pretrained(model_name)
|
| 211 |
model = AutoModel.from_pretrained(model_name)
|
| 212 |
|
|
@@ -228,7 +228,8 @@ def run_siglip_inference(image_paths, class_names):
|
|
| 228 |
text=prompts,
|
| 229 |
images=image,
|
| 230 |
return_tensors="pt",
|
| 231 |
-
padding="max_length"
|
|
|
|
| 232 |
).to(device)
|
| 233 |
|
| 234 |
outputs = model(**inputs)
|
|
@@ -333,8 +334,8 @@ def main():
|
|
| 333 |
# Handle different models with appropriate methods
|
| 334 |
if model_name in ["imageomics/bioclip", "imageomics/bioclip-2"]:
|
| 335 |
results = run_bioclip_inference(model_name, image_paths, CLASS_NAMES)
|
| 336 |
-
elif model_name
|
| 337 |
-
results = run_siglip_inference(image_paths, CLASS_NAMES)
|
| 338 |
elif model_name in ["facebook/PE-Core-L14-336", "laion/CLIP-ViT-L-14-laion2B-s32B-b82K"]:
|
| 339 |
results = run_openclip_inference(model_name, image_paths, CLASS_NAMES)
|
| 340 |
else:
|
|
|
|
| 46 |
MODELS = [
|
| 47 |
"openai/clip-vit-large-patch14",
|
| 48 |
"google/siglip2-large-patch16-384",
|
| 49 |
+
"google/siglip2-large-patch16-512",
|
| 50 |
+
"google/siglip2-so400m-patch16-naflex",
|
| 51 |
"imageomics/bioclip",
|
| 52 |
"imageomics/bioclip-2",
|
| 53 |
"facebook/PE-Core-L14-336",
|
|
|
|
| 202 |
print(f"Error loading OpenCLIP model {model_name}: {e}")
|
| 203 |
return None
|
| 204 |
|
| 205 |
+
def run_siglip_inference(model_name, image_paths, class_names):
|
| 206 |
"""Run zero-shot inference using SigLIP with manual CLIP-style computation."""
|
| 207 |
+
print(f"Loading SigLIP model: {model_name}")
|
| 208 |
try:
|
| 209 |
from transformers import AutoProcessor, AutoModel
|
|
|
|
|
|
|
| 210 |
processor = AutoProcessor.from_pretrained(model_name)
|
| 211 |
model = AutoModel.from_pretrained(model_name)
|
| 212 |
|
|
|
|
| 228 |
text=prompts,
|
| 229 |
images=image,
|
| 230 |
return_tensors="pt",
|
| 231 |
+
padding="max_length",
|
| 232 |
+
truncation=True
|
| 233 |
).to(device)
|
| 234 |
|
| 235 |
outputs = model(**inputs)
|
|
|
|
| 334 |
# Handle different models with appropriate methods
|
| 335 |
if model_name in ["imageomics/bioclip", "imageomics/bioclip-2"]:
|
| 336 |
results = run_bioclip_inference(model_name, image_paths, CLASS_NAMES)
|
| 337 |
+
elif model_name.startswith("google/siglip"):
|
| 338 |
+
results = run_siglip_inference(model_name, image_paths, CLASS_NAMES)
|
| 339 |
elif model_name in ["facebook/PE-Core-L14-336", "laion/CLIP-ViT-L-14-laion2B-s32B-b82K"]:
|
| 340 |
results = run_openclip_inference(model_name, image_paths, CLASS_NAMES)
|
| 341 |
else:
|
iwildcam_demo.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f31fb9889d96fcecb5899a12e03102cbebac1d02a1689770ca734d748333286c
|
| 3 |
+
size 272
|
models.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
facebook/PE-Core-L14-336
|
| 2 |
google/siglip2-so400m-patch16-naflex
|
| 3 |
openai/clip-vit-large-patch14
|
| 4 |
-
imageomics/bioclip-
|
| 5 |
laion/CLIP-ViT-L-14-laion2B-s32B-b82K
|
|
|
|
| 1 |
facebook/PE-Core-L14-336
|
| 2 |
google/siglip2-so400m-patch16-naflex
|
| 3 |
openai/clip-vit-large-patch14
|
| 4 |
+
imageomics/bioclip-v2
|
| 5 |
laion/CLIP-ViT-L-14-laion2B-s32B-b82K
|
process_iwildcam_data.py
CHANGED
|
@@ -52,11 +52,11 @@ def create_tensors():
|
|
| 52 |
|
| 53 |
# Load model predictions
|
| 54 |
model_files = [
|
| 55 |
-
|
| 56 |
-
'
|
| 57 |
-
|
| 58 |
-
'
|
| 59 |
-
|
| 60 |
]
|
| 61 |
models, all_predictions, class_names = load_model_predictions(model_files)
|
| 62 |
|
|
|
|
| 52 |
|
| 53 |
# Load model predictions
|
| 54 |
model_files = [
|
| 55 |
+
'zeroshot_results_facebook_PE_Core_L14_336.json',
|
| 56 |
+
'zeroshot_results_google_siglip2_so400m_patch16_naflex.json',
|
| 57 |
+
'zeroshot_results_openai_clip_vit_large_patch14.json',
|
| 58 |
+
'zeroshot_results_imageomics_bioclip_v2.json',
|
| 59 |
+
'zeroshot_results_laion_CLIP_ViT_L_14_laion2B_s32B_b82K.json',
|
| 60 |
]
|
| 61 |
models, all_predictions, class_names = load_model_predictions(model_files)
|
| 62 |
|