bassatbassat commited on
Commit
5ffd008
·
verified ·
1 Parent(s): 2ded2cc

docs: model card and links

Browse files
Files changed (2) hide show
  1. README.md +105 -1
  2. best_metadata.json +0 -98
README.md CHANGED
@@ -1,3 +1,107 @@
1
  ---
2
- license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: cc-by-nc-4.0
3
+ library_name: pytorch
4
+ pipeline_tag: image-feature-extraction
5
+ base_model: BVRA/MegaDescriptor-L-384
6
+ datasets:
7
+ - Made-In-Alexandria-AI/ApexID-Dataset
8
+ tags:
9
+ - animal-re-identification
10
+ - re-identification
11
+ - wildlife
12
+ - metric-learning
13
+ - apexid
14
+ - megadescriptor
15
+ - swin-transformer
16
  ---
17
+ # ApexID MegaDescriptor-L encoder
18
+
19
+ [Project page](https://mia-ai-team.github.io/ApexID-Hierarchical-Learning-for-Multi-Species-Animal-Re-Identification-Official-Repo/) · [Code](https://github.com/MIA-AI-Team/ApexID-Hierarchical-Learning-for-Multi-Species-Animal-Re-Identification-Official-Repo) · [Dataset](https://huggingface.co/datasets/Made-In-Alexandria-AI/ApexID-Dataset) · Paper: arXiv link coming soon
20
+
21
+ This is the MegaDescriptor-L image encoder from *ApexID: Hierarchical Learning for Multi-Species Animal Re-Identification*, trained with the ApexID Hierarchical Loss. It maps a segmented animal image to an L2-normalized embedding, so individuals of any species can be matched by cosine similarity. In the paper it gives +7.17 Rank-1 over the original MegaDescriptor-L checkpoint and +2.98 over the best baseline loss on the same backbone.
22
+
23
+ The other ApexID encoders are [ApexID_ConvNext_Backbone](https://huggingface.co/Made-In-Alexandria-AI/ApexID_ConvNext_Backbone) and [ApexID_MiewID_Backbone](https://huggingface.co/Made-In-Alexandria-AI/ApexID_MiewID_Backbone).
24
+
25
+ ## Model details
26
+
27
+ | | |
28
+ | --- | --- |
29
+ | Architecture | MegaDescriptor-L |
30
+ | Initialization | [BVRA/MegaDescriptor-L-384](https://huggingface.co/BVRA/MegaDescriptor-L-384) at revision `33b3c6f4ee0c386a4126cc3dcd23843920613fa1` |
31
+ | Parameters | 195.20M |
32
+ | Embedding | 1536-d, L2-normalized |
33
+ | Input | 384 × 384 RGB, normalized with mean (0.5, 0.5, 0.5) and std (0.5, 0.5, 0.5) |
34
+ | File | `best_backbone.pt` (PyTorch state dict) |
35
+ | Matching config | [`configs/megadescriptor_l/apexid_hierarchical.yaml`](https://github.com/MIA-AI-Team/ApexID-Hierarchical-Learning-for-Multi-Species-Animal-Re-Identification-Official-Repo/blob/main/configs/megadescriptor_l/apexid_hierarchical.yaml) |
36
+
37
+ ## Usage
38
+
39
+ Install the [ApexID repository](https://github.com/MIA-AI-Team/ApexID-Hierarchical-Learning-for-Multi-Species-Animal-Re-Identification-Official-Repo) and run from its root:
40
+
41
+ ```python
42
+ import numpy as np
43
+ import torch
44
+ from PIL import Image
45
+ from huggingface_hub import hf_hub_download
46
+
47
+ from apexid.data import build_eval_transforms
48
+ from apexid.evaluation.embeddings import ApexIDModelAdapter
49
+ from apexid.utils.config import load_config
50
+
51
+ config = load_config(config_path="configs/megadescriptor_l/apexid_hierarchical.yaml")
52
+ weights = hf_hub_download("Made-In-Alexandria-AI/ApexID_MegaDescriptor_Backbone", "best_backbone.pt")
53
+
54
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
55
+ model = ApexIDModelAdapter.from_checkpoint(config, weights, device).model
56
+ transform = build_eval_transforms(config=config)
57
+
58
+ rgb = np.asarray(Image.open("animal.png").convert("RGB")) # a segmented foreground works best
59
+ with torch.inference_mode():
60
+ embedding = model(transform(image=rgb)["image"][None].to(device)) # shape (1, 1536)
61
+ ```
62
+
63
+ ## Results
64
+
65
+ Closed-set retrieval, averaged over four external datasets (ELPephants, GCN-ID, Bristol Gorillas and private jaguar data) and five observation-disjoint split seeds, in percent. All rows use the MegaDescriptor-L backbone.
66
+
67
+ | Model | Rank-1 | mAP | mINP |
68
+ | --- | ---: | ---: | ---: |
69
+ | Pretrained MegaDescriptor-L | 54.01 | 23.62 | 10.66 |
70
+ | ArcFace | 58.20 | 27.13 | 13.05 |
71
+ | Dynamic ArcFace | 55.44 | 25.51 | 11.75 |
72
+ | SphereFace2 | 57.13 | 26.61 | 12.47 |
73
+ | **ApexID Hierarchical (this model)** | 61.18 | 29.07 | 14.69 |
74
+
75
+ Transfer to ELPephants, a category absent from all animal Re-ID training, in percent:
76
+
77
+ | Model | Rank-1 | mAP |
78
+ | --- | ---: | ---: |
79
+ | Original MegaDescriptor-L checkpoint | 8.63 | 3.34 |
80
+ | ApexID Hierarchical (this model) | 13.79 | 4.94 |
81
+
82
+ The [project page](https://mia-ai-team.github.io/ApexID-Hierarchical-Learning-for-Multi-Species-Animal-Re-Identification-Official-Repo/) has the full fourteen-configuration comparison, the open-set evaluation and ScoreCAM maps.
83
+
84
+ ## Intended use and limitations
85
+
86
+ The encoder is meant for research on individual animal re-identification: ranking a gallery of known individuals against a query image, or clustering images of unknown individuals. It works best on segmented foregrounds like those it was trained on. Absolute scores on unseen species remain low, and open-set results vary by dataset, so verify matches with an expert before acting on them.
87
+
88
+ ## Training data
89
+
90
+ The encoder was trained on the ApexID corpus: 132,533 curated images of 13,348 identities from 19 public animal re-identification datasets. See the [dataset card](https://huggingface.co/datasets/Made-In-Alexandria-AI/ApexID-Dataset) for sources, licenses and splits.
91
+
92
+ ## License
93
+
94
+ The ApexID code is MIT-licensed. These weights are fine-tuned from [BVRA/MegaDescriptor-L-384](https://huggingface.co/BVRA/MegaDescriptor-L-384) and keep its CC BY-NC 4.0 license: non-commercial use only, with attribution.
95
+
96
+ ## Citation
97
+
98
+ ```bibtex
99
+ @article{elkerdany2026apexid,
100
+ title = {ApexID: Hierarchical Learning for Multi-Species Animal Re-Identification},
101
+ author = {Elkerdany, Seifeldin and ElBassat, Mohamed and Abouelhamd, Gamal and
102
+ Elkady, Assem and Ghoneim, Jana and Mahmood, Matin and
103
+ Martin, Abigail Allen and de Melo, Gerard and Rueda-Toicen, Antonio},
104
+ journal = {arXiv preprint},
105
+ year = {2026}
106
+ }
107
+ ```
best_metadata.json DELETED
@@ -1,98 +0,0 @@
1
- {
2
- "monitor": "none (no best selection; extracted from final epoch)",
3
- "best_epoch": 149,
4
- "source": "last_checkpoint.pt model_state_dict['backbone.*']",
5
- "metrics": {
6
- "train_loss": 0.061130401865303725,
7
- "loss_id_global": 0.059024606163049456,
8
- "train/loss_id_global": 0.059024606163049456,
9
- "loss_species": 0.0042115913677803225,
10
- "train/loss_species": 0.0042115913677803225,
11
- "balanced_species_loss": 0.0042115913677803225,
12
- "train/balanced_species_loss": 0.0042115913677803225,
13
- "loss_within_species": 0.05099253901411635,
14
- "train/loss_within_species": 0.05099253901411635,
15
- "loss_hierarchy": 0.027602065213575538,
16
- "train/loss_hierarchy": 0.027602065213575538,
17
- "loss_species_weighted": 0.0021057956838901612,
18
- "train/loss_species_weighted": 0.0021057956838901612,
19
- "loss_within_species_weighted": 0.0,
20
- "train/loss_within_species_weighted": 0.0,
21
- "loss_hierarchy_weighted": 0.0021057956838901612,
22
- "train/loss_hierarchy_weighted": 0.0021057956838901612,
23
- "loss_total": 0.061130401865303725,
24
- "train/loss_total": 0.061130401865303725,
25
- "hierarchy_weight": 0.09999999999999734,
26
- "train/hierarchy_weight": 0.09999999999999734,
27
- "species_weight": 0.5,
28
- "train/species_weight": 0.5,
29
- "within_species_weight": 0.0,
30
- "train/within_species_weight": 0.0,
31
- "within_negatives_summed": 1.0,
32
- "train/within_negatives_summed": 1.0,
33
- "identity_top1_proxy_accuracy": 0.9983164612676056,
34
- "train/identity_top1_proxy_accuracy": 0.9983164612676056,
35
- "identity_positive_similarity": 0.6116733074607984,
36
- "train/identity_positive_similarity": 0.6116733074607984,
37
- "identity_hardest_global_negative_similarity": 0.12243234207197815,
38
- "train/identity_hardest_global_negative_similarity": 0.12243234207197815,
39
- "identity_global_similarity_gap": 0.4892409662335691,
40
- "train/identity_global_similarity_gap": 0.4892409662335691,
41
- "species_valid_anchors": 64.0,
42
- "train/species_valid_anchors": 64.0,
43
- "species_weight_min": 0.1523658186197281,
44
- "train/species_weight_min": 0.1523658186197281,
45
- "species_weight_mean": 1.0000001192092896,
46
- "train/species_weight_mean": 1.0000001192092896,
47
- "species_weight_max": 2.412147045135498,
48
- "train/species_weight_max": 2.412147045135498,
49
- "species_accuracy": 0.9999889964788733,
50
- "train/species_accuracy": 0.9999889964788733,
51
- "species_positive_cosine": 0.2653320205043739,
52
- "train/species_positive_cosine": 0.2653320205043739,
53
- "species_hardest_wrong_cosine": -0.027797803576235514,
54
- "train/species_hardest_wrong_cosine": -0.027797803576235514,
55
- "species_margin_violation_rate": 8.802816901408451e-05,
56
- "train/species_margin_violation_rate": 8.802816901408451e-05,
57
- "species_effective_contribution_min": 0.0,
58
- "train/species_effective_contribution_min": 0.0,
59
- "species_effective_contribution_max": 0.32071309429658973,
60
- "train/species_effective_contribution_max": 0.32071309429658973,
61
- "species_effective_contribution_entropy": 1.5976253992025282,
62
- "train/species_effective_contribution_entropy": 1.5976253992025282,
63
- "within_valid_anchors": 64.0,
64
- "train/within_valid_anchors": 64.0,
65
- "within_candidate_identities_mean": 4208.564920774648,
66
- "train/within_candidate_identities_mean": 4208.564920774648,
67
- "within_candidate_identities_min": 200.5169014084507,
68
- "train/within_candidate_identities_min": 200.5169014084507,
69
- "within_candidate_identities_median": 4821.248591549296,
70
- "train/within_candidate_identities_median": 4821.248591549296,
71
- "within_candidate_identities_max": 6767.0,
72
- "train/within_candidate_identities_max": 6767.0,
73
- "within_true_identity_cosine": 0.6116733079225245,
74
- "train/within_true_identity_cosine": 0.6116733079225245,
75
- "within_hardest_negative_cosine": 0.12192085394766969,
76
- "train/within_hardest_negative_cosine": 0.12192085394766969,
77
- "within_cosine_gap": 0.489752454992751,
78
- "train/within_cosine_gap": 0.489752454992751,
79
- "within_violation_rate": 0.0016725352112676056,
80
- "train/within_violation_rate": 0.0016725352112676056,
81
- "within_singleton_anchors_skipped": 0.0,
82
- "train/within_singleton_anchors_skipped": 0.0,
83
- "subcenter_fraction_ever_selected": 0.8734263777732849,
84
- "train/subcenter_fraction_ever_selected": 0.8734263777732849,
85
- "subcenter_average_active_per_identity": 1.7468527555465698,
86
- "train/subcenter_average_active_per_identity": 1.7468527555465698,
87
- "subcenter_collapse_dominance": 0.93773670318261,
88
- "train/subcenter_collapse_dominance": 0.93773670318261,
89
- "winning_subcenter_fraction_0": 0.5015404929577465,
90
- "train/winning_subcenter_fraction_0": 0.5015404929577465,
91
- "winning_subcenter_fraction_1": 0.4984595070422535,
92
- "train/winning_subcenter_fraction_1": 0.4984595070422535,
93
- "identities_using_1_subcenters": 2956.0,
94
- "train/identities_using_1_subcenters": 2956.0,
95
- "identities_using_2_subcenters": 8721.0,
96
- "train/identities_using_2_subcenters": 8721.0
97
- }
98
- }