anonymous-eval commited on
Commit
2e2eb08
·
verified ·
1 Parent(s): 17974e8

Upload dinov3_custom food classifier from run 3: eps_8

Browse files
README.md ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ pipeline_tag: image-classification
5
+ base_model: facebook/dinov3-vitl16-pretrain-lvd1689m
6
+ tags:
7
+ - image-classification
8
+ - food-recognition
9
+ - dinov3
10
+ - vision-transformer
11
+ - pytorch
12
+ - tsotsa-img
13
+ datasets:
14
+ - TSOTSA-Img
15
+ metrics:
16
+ - accuracy
17
+ - f1
18
+ ---
19
+
20
+ # DINOv3-food
21
+
22
+ DINOv3-food is a food image recognition model fine-tuned from
23
+ [`facebook/dinov3-vitl16-pretrain-lvd1689m`](https://huggingface.co/facebook/dinov3-vitl16-pretrain-lvd1689m)
24
+ on TSOTSA-Img, a merged food image dataset built from AFD, FruitVeg-81,
25
+ Food-101, and UECFood256.
26
+
27
+ The model predicts 389 food categories and uses a DINOv3 ViT-L/16 backbone
28
+ with a lightweight linear classification head.
29
+
30
+ ## Dataset
31
+
32
+ TSOTSA-Img is the merged dataset used for food recognition in this work. It is
33
+ split into training and test subsets:
34
+
35
+ - Training split: used to fine-tune the model.
36
+ - Test split: used for final evaluation.
37
+
38
+ The merged dataset combines food images and labels from:
39
+
40
+ - AFD
41
+ - FruitVeg-81
42
+ - Food-101
43
+ - UECFood256
44
+
45
+ ## Training
46
+
47
+ The selected checkpoint was fine-tuned for 8 epochs.
48
+
49
+ | Setting | Value |
50
+ |---|---:|
51
+ | Base model | `facebook/dinov3-vitl16-pretrain-lvd1689m` |
52
+ | Backbone | DINOv3 ViT-L/16 |
53
+ | Number of labels | 389 |
54
+ | Epochs | 8 |
55
+ | Batch size | 16 |
56
+ | Learning rate | `2e-5` |
57
+ | Weight decay | `0.01` |
58
+ | Warmup ratio | `0.05` |
59
+ | Validation selection | best validation behavior, with emphasis on validation loss |
60
+
61
+ Validation metrics for the selected run:
62
+
63
+ | Metric | Value |
64
+ |---|---:|
65
+ | Validation loss | 0.1100 |
66
+ | Accuracy | 0.9731 |
67
+ | Macro-F1 | 0.9727 |
68
+ | Top-5 accuracy | 0.9968 |
69
+
70
+ ## Evaluation
71
+
72
+ Final evaluation was performed on the individual source datasets and on the
73
+ merged TSOTSA-Img test split.
74
+
75
+ | Dataset | Accuracy |
76
+ |---|---:|
77
+ | FruitVeg-81 | 0.9976 |
78
+ | AFD | 0.9997 |
79
+ | Food-101 | 0.9551 |
80
+ | UECFood256 | 0.8215 |
81
+ | TSOTSA-Img test | 0.9062 |
82
+
83
+ For the TSOTSA-Img test split:
84
+
85
+ | Metric | Value |
86
+ |---|---:|
87
+ | Accuracy | 0.9062 |
88
+ | Macro-F1 | 0.9072 |
89
+
90
+ ## Model format
91
+
92
+ This repository stores a custom backbone-plus-classifier model:
93
+
94
+ - `backbone/`: DINOv3 backbone saved with `transformers`.
95
+ - `classifier.pt`: linear classification head.
96
+ - `classifier_config.json`: label mappings and classifier metadata.
97
+ - `preprocessor_config.json`: image preprocessing configuration.
98
+
99
+ Because this model uses a custom wrapper around the DINOv3 backbone, loading it
100
+ with `AutoModelForImageClassification.from_pretrained(...)` is not sufficient.
101
+ Use the project loader or reconstruct the wrapper before inference.
102
+
103
+ ## Usage
104
+
105
+ Example with the project inference class:
106
+
107
+ ```python
108
+ from inference.food_classifier import FoodClassifier
109
+
110
+ model_dir = "model_saved/finetuning/facebook-dinov3-vitl16-pretrain-lvd1689m/epochs_8"
111
+ classifier = FoodClassifier(model_dir)
112
+
113
+ prediction = classifier.predict("path/to/food_image.jpg")
114
+ print(prediction)
115
+ ```
116
+
117
+ Manual loading:
118
+
119
+ ```python
120
+ import json
121
+ import torch
122
+ from transformers import AutoImageProcessor, AutoModel
123
+ from finetuning.train_classifier import BackboneImageClassifier
124
+
125
+ model_dir = "model_saved/finetuning/facebook-dinov3-vitl16-pretrain-lvd1689m/epochs_8"
126
+
127
+ with open(f"{model_dir}/classifier_config.json", "r", encoding="utf-8") as f:
128
+ classifier_config = json.load(f)
129
+
130
+ id2label = {
131
+ int(label_id): label
132
+ for label_id, label in classifier_config["id2label"].items()
133
+ }
134
+ label2id = {
135
+ label: int(label_id)
136
+ for label, label_id in classifier_config["label2id"].items()
137
+ }
138
+
139
+ backbone = AutoModel.from_pretrained(f"{model_dir}/backbone")
140
+ model = BackboneImageClassifier(
141
+ backbone=backbone,
142
+ num_labels=int(classifier_config["num_labels"]),
143
+ id2label=id2label,
144
+ label2id=label2id,
145
+ )
146
+
147
+ classifier_state = torch.load(f"{model_dir}/classifier.pt", map_location="cpu")
148
+ model.classifier.load_state_dict(classifier_state)
149
+ model.eval()
150
+
151
+ processor = AutoImageProcessor.from_pretrained(model_dir)
152
+ ```
153
+
154
+ ## Intended use
155
+
156
+ This model is intended for food image recognition over the TSOTSA-Img label
157
+ space. It can be used for research experiments, dataset benchmarking, and food
158
+ recognition pipelines where the target labels overlap with the 389 supported
159
+ categories.
160
+
161
+ ## Limitations
162
+
163
+ - The model is restricted to the 389 labels in `classifier_config.json`.
164
+ - Performance may degrade on food categories outside the TSOTSA-Img label
165
+ space.
166
+ - Predictions may be sensitive to ambiguous images, mixed dishes, heavy
167
+ occlusion, or visually similar food categories.
168
+ - The model card reports accuracy on the available benchmark splits and should
169
+ not be interpreted as performance on all possible food domains.
170
+
171
+ ## Citation
all_results.json CHANGED
@@ -1,21 +1,21 @@
1
  {
2
  "epoch": 8.0,
3
- "eval_accuracy": 0.9731962296486718,
4
- "eval_f1_macro": 0.97272463600211,
5
- "eval_loss": 0.11423125863075256,
6
- "eval_runtime": 215.0703,
7
- "eval_samples_per_second": 135.653,
8
- "eval_steps_per_second": 11.308,
9
- "eval_top5_accuracy": 0.9967780634104542,
10
- "run_wall_time_hours": 12.102496446039941,
11
- "run_wall_time_minutes": 726.1497867623965,
12
- "run_wall_time_seconds": 43568.98720574379,
13
  "total_flos": 0.0,
14
- "train_loss": 0.446697575658745,
15
- "train_runtime": 43197.8762,
16
- "train_samples_per_second": 48.627,
17
- "train_steps_per_second": 4.052,
18
- "train_wall_time_hours": 11.99947108036942,
19
- "train_wall_time_minutes": 719.9682648221652,
20
- "train_wall_time_seconds": 43198.09588932991
21
  }
 
1
  {
2
  "epoch": 8.0,
3
+ "eval_accuracy": 0.9730591259640102,
4
+ "eval_f1_macro": 0.9727023139698624,
5
+ "eval_loss": 0.11002838611602783,
6
+ "eval_runtime": 216.4171,
7
+ "eval_samples_per_second": 134.809,
8
+ "eval_steps_per_second": 8.428,
9
+ "eval_top5_accuracy": 0.996846615252785,
10
+ "run_wall_time_hours": 10.413995842536291,
11
+ "run_wall_time_minutes": 624.8397505521774,
12
+ "run_wall_time_seconds": 37490.385033130646,
13
  "total_flos": 0.0,
14
+ "train_loss": 0.37596295774437,
15
+ "train_runtime": 37253.6996,
16
+ "train_samples_per_second": 56.386,
17
+ "train_steps_per_second": 3.524,
18
+ "train_wall_time_hours": 10.348306588000721,
19
+ "train_wall_time_minutes": 620.8983952800432,
20
+ "train_wall_time_seconds": 37253.9037168026
21
  }
backbone/model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:860eb2b858e1dcc139302a2c875fce78df92f77d933e8500b98444954fb5fe6c
3
  size 1212559808
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4623464dfa91314a072783b772355546571b4ce0d54bc17287e7c464c84e26e7
3
  size 1212559808
classifier.pt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:be0cee77682c3acbca96fc00edb13843acf273371a5600c06659bcab99e535d7
3
  size 1596861
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e5941cc94cb6e61f79a00830562beb2356b174bda58772243d6b8fef29407777
3
  size 1596861
eval_results.json CHANGED
@@ -1,10 +1,10 @@
1
  {
2
  "epoch": 8.0,
3
- "eval_accuracy": 0.9731962296486718,
4
- "eval_f1_macro": 0.97272463600211,
5
- "eval_loss": 0.11423125863075256,
6
- "eval_runtime": 215.0703,
7
- "eval_samples_per_second": 135.653,
8
- "eval_steps_per_second": 11.308,
9
- "eval_top5_accuracy": 0.9967780634104542
10
  }
 
1
  {
2
  "epoch": 8.0,
3
+ "eval_accuracy": 0.9730591259640102,
4
+ "eval_f1_macro": 0.9727023139698624,
5
+ "eval_loss": 0.11002838611602783,
6
+ "eval_runtime": 216.4171,
7
+ "eval_samples_per_second": 134.809,
8
+ "eval_steps_per_second": 8.428,
9
+ "eval_top5_accuracy": 0.996846615252785
10
  }
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7228be9fd21ce92856b879364aa3b773ae88f325a050411162237b2c748b6e37
3
  size 1214158628
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a8b6e793374a9998ffd81330b87bc3e5ea7d675652abed91c317a66d6a8a71e1
3
  size 1214158628
run_summary.json CHANGED
@@ -6,37 +6,37 @@
6
  "output_dir": "./model_saved/finetuning/facebook-dinov3-vitl16-pretrain-lvd1689m/epochs_8",
7
  "logging_dir": "./finetuning/logs/runs/facebook-dinov3-vitl16-pretrain-lvd1689m/epochs_8",
8
  "cache_dir": "./cached_dataset/finetuning/facebook-dinov3-vitl16-pretrain-lvd1689m",
9
- "started_at": "2026-06-14T07:33:22.181034+00:00",
10
- "train_finished_at": "2026-06-14T19:33:20.276955+00:00",
11
- "finished_at": "2026-06-14T19:39:31.168271+00:00",
12
- "train_duration_seconds": 43198.09588932991,
13
- "train_duration_minutes": 719.9682648221652,
14
- "train_duration_hours": 11.99947108036942,
15
- "run_duration_seconds": 43568.98720574379,
16
- "run_duration_minutes": 726.1497867623965,
17
- "run_duration_hours": 12.102496446039941,
18
  "train_metrics": {
19
- "train_runtime": 43197.8762,
20
- "train_samples_per_second": 48.627,
21
- "train_steps_per_second": 4.052,
22
  "total_flos": 0.0,
23
- "train_loss": 0.446697575658745,
24
  "epoch": 8.0,
25
- "train_wall_time_seconds": 43198.09588932991,
26
- "train_wall_time_minutes": 719.9682648221652,
27
- "train_wall_time_hours": 11.99947108036942,
28
- "run_wall_time_seconds": 43568.98720574379,
29
- "run_wall_time_minutes": 726.1497867623965,
30
- "run_wall_time_hours": 12.102496446039941
31
  },
32
  "eval_metrics": {
33
- "eval_loss": 0.11423125863075256,
34
- "eval_accuracy": 0.9731962296486718,
35
- "eval_f1_macro": 0.97272463600211,
36
- "eval_top5_accuracy": 0.9967780634104542,
37
- "eval_runtime": 215.0703,
38
- "eval_samples_per_second": 135.653,
39
- "eval_steps_per_second": 11.308,
40
  "epoch": 8.0
41
  }
42
  }
 
6
  "output_dir": "./model_saved/finetuning/facebook-dinov3-vitl16-pretrain-lvd1689m/epochs_8",
7
  "logging_dir": "./finetuning/logs/runs/facebook-dinov3-vitl16-pretrain-lvd1689m/epochs_8",
8
  "cache_dir": "./cached_dataset/finetuning/facebook-dinov3-vitl16-pretrain-lvd1689m",
9
+ "started_at": "2026-06-16T11:27:32.527592+00:00",
10
+ "train_finished_at": "2026-06-16T21:48:26.431336+00:00",
11
+ "finished_at": "2026-06-16T21:52:22.912657+00:00",
12
+ "train_duration_seconds": 37253.9037168026,
13
+ "train_duration_minutes": 620.8983952800432,
14
+ "train_duration_hours": 10.348306588000721,
15
+ "run_duration_seconds": 37490.385033130646,
16
+ "run_duration_minutes": 624.8397505521774,
17
+ "run_duration_hours": 10.413995842536291,
18
  "train_metrics": {
19
+ "train_runtime": 37253.6996,
20
+ "train_samples_per_second": 56.386,
21
+ "train_steps_per_second": 3.524,
22
  "total_flos": 0.0,
23
+ "train_loss": 0.37596295774437,
24
  "epoch": 8.0,
25
+ "train_wall_time_seconds": 37253.9037168026,
26
+ "train_wall_time_minutes": 620.8983952800432,
27
+ "train_wall_time_hours": 10.348306588000721,
28
+ "run_wall_time_seconds": 37490.385033130646,
29
+ "run_wall_time_minutes": 624.8397505521774,
30
+ "run_wall_time_hours": 10.413995842536291
31
  },
32
  "eval_metrics": {
33
+ "eval_loss": 0.11002838611602783,
34
+ "eval_accuracy": 0.9730591259640102,
35
+ "eval_f1_macro": 0.9727023139698624,
36
+ "eval_top5_accuracy": 0.996846615252785,
37
+ "eval_runtime": 216.4171,
38
+ "eval_samples_per_second": 134.809,
39
+ "eval_steps_per_second": 8.428,
40
  "epoch": 8.0
41
  }
42
  }
train_results.json CHANGED
@@ -1,14 +1,14 @@
1
  {
2
  "epoch": 8.0,
3
- "run_wall_time_hours": 12.102496446039941,
4
- "run_wall_time_minutes": 726.1497867623965,
5
- "run_wall_time_seconds": 43568.98720574379,
6
  "total_flos": 0.0,
7
- "train_loss": 0.446697575658745,
8
- "train_runtime": 43197.8762,
9
- "train_samples_per_second": 48.627,
10
- "train_steps_per_second": 4.052,
11
- "train_wall_time_hours": 11.99947108036942,
12
- "train_wall_time_minutes": 719.9682648221652,
13
- "train_wall_time_seconds": 43198.09588932991
14
  }
 
1
  {
2
  "epoch": 8.0,
3
+ "run_wall_time_hours": 10.413995842536291,
4
+ "run_wall_time_minutes": 624.8397505521774,
5
+ "run_wall_time_seconds": 37490.385033130646,
6
  "total_flos": 0.0,
7
+ "train_loss": 0.37596295774437,
8
+ "train_runtime": 37253.6996,
9
+ "train_samples_per_second": 56.386,
10
+ "train_steps_per_second": 3.524,
11
+ "train_wall_time_hours": 10.348306588000721,
12
+ "train_wall_time_minutes": 620.8983952800432,
13
+ "train_wall_time_seconds": 37253.9037168026
14
  }
trainer_log_history.json CHANGED
The diff for this file is too large to render. See raw diff