tit0000 commited on
Commit
2a1ffd0
·
verified ·
1 Parent(s): 424bffe

V1 models, app assets and model card

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ gallery.json filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,125 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ tags:
4
+ - image-feature-extraction
5
+ - LiteRT
6
+ - wildlife
7
+ - animal-re-identification
8
+ - face-recognition
9
+ - arcface
10
+ - megadescriptor
11
+ - gorilla
12
+ - open-set
13
+ pipeline_tag: image-feature-extraction
14
  ---
15
+
16
+ # GorillaIdentifier
17
+
18
+ Individual facial recognition for mountain gorillas (*Gorilla beringei beringei*, Virunga), from field photographs to an offline Android deployment.
19
+
20
+ - Source code (ML pipeline): https://github.com/tit-exe/GorillaIdentifier
21
+ - Source code (Android app): https://github.com/tit-exe/GorillaIdentifier_AndroidApp
22
+
23
+ ## Overview
24
+
25
+ This project trains a face detector and an individual identification model from labeled field
26
+ photographs, then exports the result as a lightweight gallery JSON for an Android app that runs
27
+ entirely offline. The gallery holds up to 25 exemplar embeddings per individual. Adding a new
28
+ individual takes a handful of photos on the phone and requires no retraining.
29
+
30
+ ## Inference pipeline
31
+
32
+ ```
33
+ Field photo -> YOLO gorilla face detection
34
+ -> 224x224 crop
35
+ -> MegaDescriptor-T-224 (Swin Transformer Tiny, 768-dim embedding)
36
+ -> max cosine similarity over the exemplars of each individual
37
+ -> Known individual (score >= 0.4689 and margin >= 0.08) or Unknown
38
+ ```
39
+
40
+ ## Android app assets
41
+
42
+ This repository hosts the assets required to run the offline Android app. The app identifies files
43
+ by role, so the recognition backbone must be downloaded here (it exceeds the GitHub 100 MB limit),
44
+ while the detector and the gallery are also bundled in the app repository:
45
+
46
+ - `megadesc_T_arcface_backbone.tflite` : the MegaDescriptor-T embedding backbone (107 MB). Download
47
+ it and place it in `app/src/main/assets/` before building the app.
48
+ - `yolo_v2_detector.tflite` : the gorilla face detector (the filename is the one the Android app
49
+ expects; it is the gorilla detector, not an orangutan model).
50
+ - `gallery.json` : the identity database, 66 individuals.
51
+
52
+ ## Models
53
+
54
+ | File | Role | Size | Description |
55
+ |------|------|------|-------------|
56
+ | `yolo_gorilla.pt` | pipeline | 18 MB | Gorilla face detector (YOLOv8), used for crop extraction and training |
57
+ | `gorilla_v1_best.pt` | pipeline | 105 MB | Trained V1 identifier checkpoint (MegaDescriptor-T + Sub-center ArcFace) |
58
+ | `megadesc_T_arcface_backbone.tflite` | app | 107 MB | Identifier backbone exported to TFLite for the Android app |
59
+ | `yolo_v2_detector.tflite` | app | 6 MB | Gorilla face detector exported to TFLite for the Android app |
60
+ | `gallery.json` | app | 30 MB | Identity gallery, 66 individuals, up to 25 exemplars each, 768-dim |
61
+
62
+ The generic MegaDescriptor-T-224 backbone used as the training starting point is not stored here.
63
+ `timm` downloads it automatically from `BVRA/MegaDescriptor-T-224` the first time training runs.
64
+
65
+ ## Performance
66
+
67
+ Version 1, 66 individuals, Virunga 2025. Metrics are measured on the held-out validation set after
68
+ training.
69
+
70
+ | Metric | Value |
71
+ |---|---|
72
+ | Recognized individuals | 66 |
73
+ | Top-1 accuracy | 93.0% |
74
+ | Top-3 accuracy | 96.1% |
75
+ | Mean F1 | 0.981 |
76
+ | Composite score | 0.808 |
77
+ | Rejection threshold | 0.4689 |
78
+ | Separability gap | 0.4351 |
79
+ | Backbone | MegaDescriptor-T-224 (Swin Transformer Tiny, 27.5M parameters) |
80
+ | Training time | about 66 minutes on an RTX 3050 4 GB |
81
+
82
+ The rejection threshold is the cosine-similarity cutoff below which a face is reported as unknown,
83
+ calibrated by maximizing F1 on the validation set. The separability gap is the average similarity
84
+ gap between an individual's own exemplars and its closest rival; a higher gap means less confusion.
85
+
86
+ ## Dataset
87
+
88
+ | Source | Individuals | Crops | Role |
89
+ |--------|-------------|-------|------|
90
+ | Field photographs (Virunga) | 66 known (+ 3 held out) | 2,809 | Training and validation |
91
+ | Internet / background images | unlabeled | 428 | Background class (pseudo-unknowns) |
92
+
93
+ Two individuals with too few crops were excluded from training, and three were held out as
94
+ pseudo-unknowns to calibrate the rejection threshold. Photographs are not included in this repository.
95
+
96
+ ## Download
97
+
98
+ ```python
99
+ from huggingface_hub import hf_hub_download
100
+
101
+ path = hf_hub_download(
102
+ repo_id="tit0000/GorillaIdentifier",
103
+ filename="gorilla_v1_best.pt",
104
+ )
105
+ ```
106
+
107
+ Or, for the pipeline detector, via the helper script in the code repository:
108
+
109
+ ```bash
110
+ python models/download_models.py
111
+ ```
112
+
113
+ ## Security note
114
+
115
+ These `.pt` files are standard PyTorch and Ultralytics checkpoints. The pickle imports flagged by
116
+ Hugging Face come from trusted libraries (torch, ultralytics, collections) and contain no malicious
117
+ code.
118
+
119
+ ## References
120
+
121
+ - Čermák et al. (2024). WildlifeDatasets. WACV 2024.
122
+ - Deng et al. (2019). ArcFace. CVPR 2019.
123
+ - Deng et al. (2020). Sub-center ArcFace. ECCV 2020.
124
+ - Liu et al. (2021). Swin Transformer. ICCV 2021.
125
+ - Khosla et al. (2020). Supervised Contrastive Learning. NeurIPS 2020.
gallery.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cbf13ddbcb13036edf2465618fcc4f3903157f18c14627560d167789e0fd55de
3
+ size 30901377
gorilla_v1_best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b87855224bff7d1fd08a014580847b0b7bd863f1349b14993046e32aa1b73bc
3
+ size 110410112
megadesc_T_arcface_backbone.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:475376e35a2d1931f693a76f583636e93743d57d718dd80127cf1b67257c7496
3
+ size 112476636
yolo_gorilla.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3cedb88b0a6d55a53d11c455d383440c07b2d048cd37a8226f3864517299bb51
3
+ size 18474390
yolo_v2_detector.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:551c92d9c179437610f075cfd92a0e8f3561749d40e89f7637d59e761ec3ffb1
3
+ size 6199005