replyquickflorida commited on
Commit
b83d525
·
verified ·
1 Parent(s): beab266

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - strangerguardhf/Tooth-Agenesis-6_Types
5
+ language:
6
+ - en
7
+ base_model:
8
+ - google/siglip2-base-patch16-512
9
+ pipeline_tag: image-classification
10
+ library_name: transformers
11
+ tags:
12
+ - tooth
13
+ - SigLIP2
14
+ - chemistry
15
+ - biology
16
+ - medical
17
+ - Calculus
18
+ - Mouth Ulcer
19
+ - hypodontia
20
+ - Tooth Discoloration
21
+ - Gingivitis
22
+ - tooth-agenesis
23
+ ---
24
+
25
+ ![123.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/9_mjg7bzNcQT-Ifx-ATmH.png)
26
+
27
+ # tooth-agenesis-siglip2
28
+
29
+ > tooth-agenesis-siglip2 is a vision-language encoder model fine-tuned from `google/siglip2-base-patch16-512` for **multi-class image classification**. It is trained to detect various **dental anomalies and conditions** such as **Calculus**, **Caries**, **Gingivitis**, **Mouth Ulcer**, **Tooth Discoloration**, and **Hypodontia**. The model uses the `SiglipForImageClassification` architecture.
30
+
31
+ > \[!note]
32
+ > SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features
33
+ > [https://arxiv.org/pdf/2502.14786](https://arxiv.org/pdf/2502.14786)
34
+
35
+ ```py
36
+ Classification Report:
37
+ precision recall f1-score support
38
+
39
+ Calculus 0.6640 0.7623 0.7098 1296
40
+ Caries 0.9525 0.9558 0.9541 2601
41
+ Gingivitis 0.8496 0.7842 0.8156 2349
42
+ Mouth Ulcer 0.9939 0.9893 0.9916 2806
43
+ Tooth Discoloration 0.9314 0.9757 0.9530 2017
44
+ hypodontia 0.9983 0.9161 0.9554 1251
45
+
46
+ accuracy 0.9096 12320
47
+ macro avg 0.8983 0.8972 0.8966 12320
48
+ weighted avg 0.9132 0.9096 0.9105 12320
49
+ ```
50
+
51
+ ![download.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/vCoLKevXThpp6GhYCvoCe.png)
52
+
53
+ ---
54
+
55
+ ## Label Space: 6 Classes
56
+
57
+ ```
58
+ Class 0: Calculus
59
+ Class 1: Caries
60
+ Class 2: Gingivitis
61
+ Class 3: Mouth Ulcer
62
+ Class 4: Tooth Discoloration
63
+ Class 5: hypodontia
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Install Dependencies
69
+
70
+ ```bash
71
+ pip install -q transformers torch pillow gradio hf_xet
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Inference Code
77
+
78
+ ```python
79
+ import gradio as gr
80
+ from transformers import AutoImageProcessor, SiglipForImageClassification
81
+ from PIL import Image
82
+ import torch
83
+
84
+ # Load model and processor
85
+ model_name = "prithivMLmods/tooth-agenesis-siglip2" # Update with actual model name on Hugging Face
86
+ model = SiglipForImageClassification.from_pretrained(model_name)
87
+ processor = AutoImageProcessor.from_pretrained(model_name)
88
+
89
+ # Updated label mapping
90
+ id2label = {
91
+ "0": "Calculus",
92
+ "1": "Caries",
93
+ "2": "Gingivitis",
94
+ "3": "Mouth Ulcer",
95
+ "4": "Tooth Discoloration",
96
+ "5": "hypodontia"
97
+ }
98
+
99
+ def classify_image(image):
100
+ image = Image.fromarray(image).convert("RGB")
101
+ inputs = processor(images=image, return_tensors="pt")
102
+
103
+ with torch.no_grad():
104
+ outputs = model(**inputs)
105
+ logits = outputs.logits
106
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
107
+
108
+ prediction = {
109
+ id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
110
+ }
111
+
112
+ return prediction
113
+
114
+ # Gradio Interface
115
+ iface = gr.Interface(
116
+ fn=classify_image,
117
+ inputs=gr.Image(type="numpy"),
118
+ outputs=gr.Label(num_top_classes=6, label="Dental Condition Classification"),
119
+ title="Tooth Agenesis Detection",
120
+ description="Upload a dental image to detect conditions such as Calculus, Caries, Gingivitis, Mouth Ulcer, Tooth Discoloration, or Hypodontia."
121
+ )
122
+
123
+ if __name__ == "__main__":
124
+ iface.launch()
125
+ ```
126
+
127
+ ---
128
+
129
+ ## Intended Use
130
+
131
+ `tooth-agenesis-siglip2` is designed for:
132
+
133
+ * **Dental Diagnosis Support** – Assists dentists and clinicians in identifying common dental conditions from images.
134
+ * **Oral Health Monitoring** – A tool for regular monitoring of dental health in clinical or remote settings.
135
+ * **Tele-dentistry** – Enables automated screening in virtual consultations and rural healthcare setups.
136
+ * **Research and Education** – Useful for academic institutions and training platforms for demonstrating AI in dental diagnostics.
137
+ * **Early Detection** – Helps identify oral health issues early to prevent progression.
checkpoint-385/config.json ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SiglipForImageClassification"
4
+ ],
5
+ "id2label": {
6
+ "0": "Calculus",
7
+ "1": "Caries",
8
+ "2": "Gingivitis",
9
+ "3": "Mouth Ulcer",
10
+ "4": "Tooth Discoloration",
11
+ "5": "hypodontia"
12
+ },
13
+ "initializer_factor": 1.0,
14
+ "label2id": {
15
+ "Calculus": 0,
16
+ "Caries": 1,
17
+ "Gingivitis": 2,
18
+ "Mouth Ulcer": 3,
19
+ "Tooth Discoloration": 4,
20
+ "hypodontia": 5
21
+ },
22
+ "model_type": "siglip",
23
+ "problem_type": "single_label_classification",
24
+ "text_config": {
25
+ "attention_dropout": 0.0,
26
+ "hidden_act": "gelu_pytorch_tanh",
27
+ "hidden_size": 768,
28
+ "intermediate_size": 3072,
29
+ "layer_norm_eps": 1e-06,
30
+ "max_position_embeddings": 64,
31
+ "model_type": "siglip_text_model",
32
+ "num_attention_heads": 12,
33
+ "num_hidden_layers": 12,
34
+ "projection_size": 768,
35
+ "torch_dtype": "float32",
36
+ "vocab_size": 256000
37
+ },
38
+ "torch_dtype": "float32",
39
+ "transformers_version": "4.50.0",
40
+ "vision_config": {
41
+ "attention_dropout": 0.0,
42
+ "hidden_act": "gelu_pytorch_tanh",
43
+ "hidden_size": 768,
44
+ "image_size": 224,
45
+ "intermediate_size": 3072,
46
+ "layer_norm_eps": 1e-06,
47
+ "model_type": "siglip_vision_model",
48
+ "num_attention_heads": 12,
49
+ "num_channels": 3,
50
+ "num_hidden_layers": 12,
51
+ "patch_size": 16,
52
+ "torch_dtype": "float32"
53
+ }
54
+ }
checkpoint-385/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52ae922fdcd72c41820710051b8899171c77749421f0cf52195f5480a5e86ec5
3
+ size 371580296
checkpoint-385/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1c24ea3ed574fc4e9c0b28cffd579c776c41c177f2df27d9495966cc12d1f1e8
3
+ size 686580346
checkpoint-385/preprocessor_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_convert_rgb": null,
3
+ "do_normalize": true,
4
+ "do_rescale": true,
5
+ "do_resize": true,
6
+ "image_mean": [
7
+ 0.5,
8
+ 0.5,
9
+ 0.5
10
+ ],
11
+ "image_processor_type": "SiglipImageProcessor",
12
+ "image_std": [
13
+ 0.5,
14
+ 0.5,
15
+ 0.5
16
+ ],
17
+ "processor_class": "SiglipProcessor",
18
+ "resample": 2,
19
+ "rescale_factor": 0.00392156862745098,
20
+ "size": {
21
+ "height": 224,
22
+ "width": 224
23
+ }
24
+ }
checkpoint-385/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:16b54ce6fd1c1a696526f20e141e670796f8dafe3b5fa3f0170630f591063c47
3
+ size 14244
checkpoint-385/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:88749df3b9c03f705cff9eb98de5f9eb8338f8b1e1f28ed21f063079c8f2170a
3
+ size 1064
checkpoint-385/trainer_state.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": 385,
3
+ "best_metric": 0.4734131693840027,
4
+ "best_model_checkpoint": "siglip2-finetune-full/checkpoint-385",
5
+ "epoch": 1.0,
6
+ "eval_steps": 500,
7
+ "global_step": 385,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 1.0,
14
+ "eval_accuracy": 0.806737012987013,
15
+ "eval_loss": 0.4734131693840027,
16
+ "eval_model_preparation_time": 0.0024,
17
+ "eval_runtime": 170.3731,
18
+ "eval_samples_per_second": 72.312,
19
+ "eval_steps_per_second": 9.039,
20
+ "step": 385
21
+ }
22
+ ],
23
+ "logging_steps": 500,
24
+ "max_steps": 770,
25
+ "num_input_tokens_seen": 0,
26
+ "num_train_epochs": 2,
27
+ "save_steps": 500,
28
+ "stateful_callbacks": {
29
+ "TrainerControl": {
30
+ "args": {
31
+ "should_epoch_stop": false,
32
+ "should_evaluate": false,
33
+ "should_log": false,
34
+ "should_save": true,
35
+ "should_training_stop": false
36
+ },
37
+ "attributes": {}
38
+ }
39
+ },
40
+ "total_flos": 1.0319019352621056e+18,
41
+ "train_batch_size": 32,
42
+ "trial_name": null,
43
+ "trial_params": null
44
+ }
checkpoint-385/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:206d195b28a5a4e1f61804a2eec06b109a4be9fa8d841f4d552fca404cebe15f
3
+ size 5304
checkpoint-770/config.json ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SiglipForImageClassification"
4
+ ],
5
+ "id2label": {
6
+ "0": "Calculus",
7
+ "1": "Caries",
8
+ "2": "Gingivitis",
9
+ "3": "Mouth Ulcer",
10
+ "4": "Tooth Discoloration",
11
+ "5": "hypodontia"
12
+ },
13
+ "initializer_factor": 1.0,
14
+ "label2id": {
15
+ "Calculus": 0,
16
+ "Caries": 1,
17
+ "Gingivitis": 2,
18
+ "Mouth Ulcer": 3,
19
+ "Tooth Discoloration": 4,
20
+ "hypodontia": 5
21
+ },
22
+ "model_type": "siglip",
23
+ "problem_type": "single_label_classification",
24
+ "text_config": {
25
+ "attention_dropout": 0.0,
26
+ "hidden_act": "gelu_pytorch_tanh",
27
+ "hidden_size": 768,
28
+ "intermediate_size": 3072,
29
+ "layer_norm_eps": 1e-06,
30
+ "max_position_embeddings": 64,
31
+ "model_type": "siglip_text_model",
32
+ "num_attention_heads": 12,
33
+ "num_hidden_layers": 12,
34
+ "projection_size": 768,
35
+ "torch_dtype": "float32",
36
+ "vocab_size": 256000
37
+ },
38
+ "torch_dtype": "float32",
39
+ "transformers_version": "4.50.0",
40
+ "vision_config": {
41
+ "attention_dropout": 0.0,
42
+ "hidden_act": "gelu_pytorch_tanh",
43
+ "hidden_size": 768,
44
+ "image_size": 224,
45
+ "intermediate_size": 3072,
46
+ "layer_norm_eps": 1e-06,
47
+ "model_type": "siglip_vision_model",
48
+ "num_attention_heads": 12,
49
+ "num_channels": 3,
50
+ "num_hidden_layers": 12,
51
+ "patch_size": 16,
52
+ "torch_dtype": "float32"
53
+ }
54
+ }
checkpoint-770/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:050405b5d29610cb6c0a9a4008b486bad93864817e9d4f6c9e901f6df4e606cd
3
+ size 371580296
checkpoint-770/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3e80777f4d487951c583c74539c6d8361faf5d62c853a6ff24e88f4d7f85a99e
3
+ size 686580346
checkpoint-770/preprocessor_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_convert_rgb": null,
3
+ "do_normalize": true,
4
+ "do_rescale": true,
5
+ "do_resize": true,
6
+ "image_mean": [
7
+ 0.5,
8
+ 0.5,
9
+ 0.5
10
+ ],
11
+ "image_processor_type": "SiglipImageProcessor",
12
+ "image_std": [
13
+ 0.5,
14
+ 0.5,
15
+ 0.5
16
+ ],
17
+ "processor_class": "SiglipProcessor",
18
+ "resample": 2,
19
+ "rescale_factor": 0.00392156862745098,
20
+ "size": {
21
+ "height": 224,
22
+ "width": 224
23
+ }
24
+ }
checkpoint-770/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ca30a322288606f938ab113b96242751c166b4bd034fa2700e7ddb17ee3d469
3
+ size 14244
checkpoint-770/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e214f8d6ea3674b15247be20b661fa60b42e2e15e99757de3d5c4a36546d8f56
3
+ size 1064
checkpoint-770/trainer_state.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": 770,
3
+ "best_metric": 0.21896059811115265,
4
+ "best_model_checkpoint": "siglip2-finetune-full/checkpoint-770",
5
+ "epoch": 2.0,
6
+ "eval_steps": 500,
7
+ "global_step": 770,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 1.0,
14
+ "eval_accuracy": 0.806737012987013,
15
+ "eval_loss": 0.4734131693840027,
16
+ "eval_model_preparation_time": 0.0024,
17
+ "eval_runtime": 170.3731,
18
+ "eval_samples_per_second": 72.312,
19
+ "eval_steps_per_second": 9.039,
20
+ "step": 385
21
+ },
22
+ {
23
+ "epoch": 1.2987012987012987,
24
+ "grad_norm": 9.846982955932617,
25
+ "learning_rate": 7.500000000000001e-05,
26
+ "loss": 0.8037,
27
+ "step": 500
28
+ },
29
+ {
30
+ "epoch": 2.0,
31
+ "eval_accuracy": 0.9095779220779221,
32
+ "eval_loss": 0.21896059811115265,
33
+ "eval_model_preparation_time": 0.0024,
34
+ "eval_runtime": 171.2991,
35
+ "eval_samples_per_second": 71.921,
36
+ "eval_steps_per_second": 8.99,
37
+ "step": 770
38
+ }
39
+ ],
40
+ "logging_steps": 500,
41
+ "max_steps": 770,
42
+ "num_input_tokens_seen": 0,
43
+ "num_train_epochs": 2,
44
+ "save_steps": 500,
45
+ "stateful_callbacks": {
46
+ "TrainerControl": {
47
+ "args": {
48
+ "should_epoch_stop": false,
49
+ "should_evaluate": false,
50
+ "should_log": false,
51
+ "should_save": true,
52
+ "should_training_stop": true
53
+ },
54
+ "attributes": {}
55
+ }
56
+ },
57
+ "total_flos": 2.0638038705242112e+18,
58
+ "train_batch_size": 32,
59
+ "trial_name": null,
60
+ "trial_params": null
61
+ }
checkpoint-770/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:206d195b28a5a4e1f61804a2eec06b109a4be9fa8d841f4d552fca404cebe15f
3
+ size 5304
config.json ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SiglipForImageClassification"
4
+ ],
5
+ "id2label": {
6
+ "0": "Calculus",
7
+ "1": "Caries",
8
+ "2": "Gingivitis",
9
+ "3": "Mouth Ulcer",
10
+ "4": "Tooth Discoloration",
11
+ "5": "hypodontia"
12
+ },
13
+ "initializer_factor": 1.0,
14
+ "label2id": {
15
+ "Calculus": 0,
16
+ "Caries": 1,
17
+ "Gingivitis": 2,
18
+ "Mouth Ulcer": 3,
19
+ "Tooth Discoloration": 4,
20
+ "hypodontia": 5
21
+ },
22
+ "model_type": "siglip",
23
+ "problem_type": "single_label_classification",
24
+ "text_config": {
25
+ "attention_dropout": 0.0,
26
+ "hidden_act": "gelu_pytorch_tanh",
27
+ "hidden_size": 768,
28
+ "intermediate_size": 3072,
29
+ "layer_norm_eps": 1e-06,
30
+ "max_position_embeddings": 64,
31
+ "model_type": "siglip_text_model",
32
+ "num_attention_heads": 12,
33
+ "num_hidden_layers": 12,
34
+ "projection_size": 768,
35
+ "torch_dtype": "float32",
36
+ "vocab_size": 256000
37
+ },
38
+ "torch_dtype": "float32",
39
+ "transformers_version": "4.50.0",
40
+ "vision_config": {
41
+ "attention_dropout": 0.0,
42
+ "hidden_act": "gelu_pytorch_tanh",
43
+ "hidden_size": 768,
44
+ "image_size": 224,
45
+ "intermediate_size": 3072,
46
+ "layer_norm_eps": 1e-06,
47
+ "model_type": "siglip_vision_model",
48
+ "num_attention_heads": 12,
49
+ "num_channels": 3,
50
+ "num_hidden_layers": 12,
51
+ "patch_size": 16,
52
+ "torch_dtype": "float32"
53
+ }
54
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:050405b5d29610cb6c0a9a4008b486bad93864817e9d4f6c9e901f6df4e606cd
3
+ size 371580296
preprocessor_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_convert_rgb": null,
3
+ "do_normalize": true,
4
+ "do_rescale": true,
5
+ "do_resize": true,
6
+ "image_mean": [
7
+ 0.5,
8
+ 0.5,
9
+ 0.5
10
+ ],
11
+ "image_processor_type": "SiglipImageProcessor",
12
+ "image_std": [
13
+ 0.5,
14
+ 0.5,
15
+ 0.5
16
+ ],
17
+ "processor_class": "SiglipProcessor",
18
+ "resample": 2,
19
+ "rescale_factor": 0.00392156862745098,
20
+ "size": {
21
+ "height": 224,
22
+ "width": 224
23
+ }
24
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:206d195b28a5a4e1f61804a2eec06b109a4be9fa8d841f4d552fca404cebe15f
3
+ size 5304