kepler2005 prithivMLmods commited on
Commit
94bc741
·
0 Parent(s):

Duplicate from prithivMLmods/Gender-Classifier-Mini

Browse files

Co-authored-by: Prithiv Sakthi <prithivMLmods@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz 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
README.md ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ base_model:
6
+ - google/siglip2-base-patch16-224
7
+ pipeline_tag: image-classification
8
+ library_name: transformers
9
+ tags:
10
+ - gender
11
+ - male
12
+ - female
13
+ - siglip2
14
+ datasets:
15
+ - myvision/gender-classification
16
+ ---
17
+
18
+ ![2.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/gfvc6sCbh9saiVnczYH2c.png)
19
+
20
+ # **Gender-Classifier-Mini**
21
+
22
+ > **Gender-Classifier-Mini** is an image classification vision-language encoder model fine-tuned from **google/siglip2-base-patch16-224** for a single-label classification task. It is designed to classify images based on gender using the **SiglipForImageClassification** architecture.
23
+
24
+ ```py
25
+ Accuracy: 0.9720
26
+ F1 Score: 0.9720
27
+
28
+ Classification Report:
29
+ precision recall f1-score support
30
+
31
+ Female ♀ 0.9660 0.9796 0.9727 2549
32
+ Male ♂ 0.9785 0.9641 0.9712 2451
33
+
34
+ accuracy 0.9720 5000
35
+ macro avg 0.9722 0.9718 0.9720 5000
36
+ weighted avg 0.9721 0.9720 0.9720 5000
37
+ ```
38
+
39
+ ![Untitled.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/MNO7bk_1wr5lvfyTDnhjF.png)
40
+
41
+ The model categorizes images into two classes:
42
+ - **Class 0:** "Female ♀"
43
+ - **Class 1:** "Male ♂"
44
+
45
+ # **Run with Transformers🤗**
46
+
47
+ ```python
48
+ !pip install -q transformers torch pillow gradio
49
+ ```
50
+
51
+ ```python
52
+ import gradio as gr
53
+ from transformers import AutoImageProcessor
54
+ from transformers import SiglipForImageClassification
55
+ from transformers.image_utils import load_image
56
+ from PIL import Image
57
+ import torch
58
+
59
+ # Load model and processor
60
+ model_name = "prithivMLmods/Gender-Classifier-Mini"
61
+ model = SiglipForImageClassification.from_pretrained(model_name)
62
+ processor = AutoImageProcessor.from_pretrained(model_name)
63
+
64
+ def gender_classification(image):
65
+ """Predicts gender category for an image."""
66
+ image = Image.fromarray(image).convert("RGB")
67
+ inputs = processor(images=image, return_tensors="pt")
68
+
69
+ with torch.no_grad():
70
+ outputs = model(**inputs)
71
+ logits = outputs.logits
72
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
73
+
74
+ labels = {"0": "Female ♀", "1": "Male ♂"}
75
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
76
+
77
+ return predictions
78
+
79
+ # Create Gradio interface
80
+ iface = gr.Interface(
81
+ fn=gender_classification,
82
+ inputs=gr.Image(type="numpy"),
83
+ outputs=gr.Label(label="Prediction Scores"),
84
+ title="Gender Classification",
85
+ description="Upload an image to classify its gender."
86
+ )
87
+
88
+ # Launch the app
89
+ if __name__ == "__main__":
90
+ iface.launch()
91
+ ```
92
+
93
+ # **Intended Use:**
94
+
95
+ The **Gender-Classifier-Mini** model is designed to classify images into gender categories. Potential use cases include:
96
+
97
+ - **Demographic Analysis:** Assisting in understanding gender distribution in datasets.
98
+ - **Face Recognition Systems:** Enhancing identity verification processes.
99
+ - **Marketing & Advertising:** Personalizing content based on demographic insights.
100
+ - **Healthcare & Research:** Supporting gender-based analysis in medical imaging.
checkpoint-157/config.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SiglipForImageClassification"
4
+ ],
5
+ "id2label": {
6
+ "0": "Female \u2640",
7
+ "1": "Male \u2642"
8
+ },
9
+ "initializer_factor": 1.0,
10
+ "label2id": {
11
+ "Female \u2640": 0,
12
+ "Male \u2642": 1
13
+ },
14
+ "model_type": "siglip",
15
+ "problem_type": "single_label_classification",
16
+ "text_config": {
17
+ "attention_dropout": 0.0,
18
+ "hidden_act": "gelu_pytorch_tanh",
19
+ "hidden_size": 768,
20
+ "intermediate_size": 3072,
21
+ "layer_norm_eps": 1e-06,
22
+ "max_position_embeddings": 64,
23
+ "model_type": "siglip_text_model",
24
+ "num_attention_heads": 12,
25
+ "num_hidden_layers": 12,
26
+ "projection_size": 768,
27
+ "torch_dtype": "float32",
28
+ "vocab_size": 256000
29
+ },
30
+ "torch_dtype": "float32",
31
+ "transformers_version": "4.51.0.dev0",
32
+ "vision_config": {
33
+ "attention_dropout": 0.0,
34
+ "hidden_act": "gelu_pytorch_tanh",
35
+ "hidden_size": 768,
36
+ "image_size": 224,
37
+ "intermediate_size": 3072,
38
+ "layer_norm_eps": 1e-06,
39
+ "model_type": "siglip_vision_model",
40
+ "num_attention_heads": 12,
41
+ "num_channels": 3,
42
+ "num_hidden_layers": 12,
43
+ "patch_size": 16,
44
+ "torch_dtype": "float32"
45
+ }
46
+ }
checkpoint-157/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4b3c881ec1fe495b6b7b22e0736bb670c36abef535d9173a427e5cbe50ffb9eb
3
+ size 371567992
checkpoint-157/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e42ca61096460c1b7078d91e3d07d3c3b5ddc67fe516b44fdf9643760658696
3
+ size 686555770
checkpoint-157/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-157/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:86d5603fb9476ef375dada75dcc320d16423a8b7cade08e44ab0230cd7431cd5
3
+ size 14244
checkpoint-157/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4e52ea243618241f112cfa55bc1203d9492a008fab26d507445786f4e9c80e8
3
+ size 1064
checkpoint-157/trainer_state.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": 157,
3
+ "best_metric": 0.11236772686243057,
4
+ "best_model_checkpoint": "siglip2-finetune-full/checkpoint-157",
5
+ "epoch": 1.0,
6
+ "eval_steps": 500,
7
+ "global_step": 157,
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.9614,
15
+ "eval_loss": 0.11236772686243057,
16
+ "eval_model_preparation_time": 0.0024,
17
+ "eval_runtime": 61.0327,
18
+ "eval_samples_per_second": 81.923,
19
+ "eval_steps_per_second": 10.24,
20
+ "step": 157
21
+ }
22
+ ],
23
+ "logging_steps": 500,
24
+ "max_steps": 314,
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": 4.1877747910656e+17,
41
+ "train_batch_size": 32,
42
+ "trial_name": null,
43
+ "trial_params": null
44
+ }
checkpoint-157/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60bfe4936cb8662967af80740b170b7ee49a77c617cfb4b4d72cb94fb4856548
3
+ size 5304
checkpoint-314/config.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SiglipForImageClassification"
4
+ ],
5
+ "id2label": {
6
+ "0": "Female \u2640",
7
+ "1": "Male \u2642"
8
+ },
9
+ "initializer_factor": 1.0,
10
+ "label2id": {
11
+ "Female \u2640": 0,
12
+ "Male \u2642": 1
13
+ },
14
+ "model_type": "siglip",
15
+ "problem_type": "single_label_classification",
16
+ "text_config": {
17
+ "attention_dropout": 0.0,
18
+ "hidden_act": "gelu_pytorch_tanh",
19
+ "hidden_size": 768,
20
+ "intermediate_size": 3072,
21
+ "layer_norm_eps": 1e-06,
22
+ "max_position_embeddings": 64,
23
+ "model_type": "siglip_text_model",
24
+ "num_attention_heads": 12,
25
+ "num_hidden_layers": 12,
26
+ "projection_size": 768,
27
+ "torch_dtype": "float32",
28
+ "vocab_size": 256000
29
+ },
30
+ "torch_dtype": "float32",
31
+ "transformers_version": "4.51.0.dev0",
32
+ "vision_config": {
33
+ "attention_dropout": 0.0,
34
+ "hidden_act": "gelu_pytorch_tanh",
35
+ "hidden_size": 768,
36
+ "image_size": 224,
37
+ "intermediate_size": 3072,
38
+ "layer_norm_eps": 1e-06,
39
+ "model_type": "siglip_vision_model",
40
+ "num_attention_heads": 12,
41
+ "num_channels": 3,
42
+ "num_hidden_layers": 12,
43
+ "patch_size": 16,
44
+ "torch_dtype": "float32"
45
+ }
46
+ }
checkpoint-314/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:672245c638f4bced0d3d2c6dc3b4c8e1b936ad88259e443dfbe919a677d3bae3
3
+ size 371567992
checkpoint-314/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca2c61bce314c08c2c635e0305545daff08656f2025c9347f009aa9877b246e3
3
+ size 686555770
checkpoint-314/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-314/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d268ac255a6c083faad4615b0dc4cbdb3cece12ea20b61aa70a45e69eb36fdc
3
+ size 14244
checkpoint-314/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b7714de473690f533461a318746634bcf917a385380970c1b2a5fed17283c74
3
+ size 1064
checkpoint-314/trainer_state.json ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": 314,
3
+ "best_metric": 0.07697099447250366,
4
+ "best_model_checkpoint": "siglip2-finetune-full/checkpoint-314",
5
+ "epoch": 2.0,
6
+ "eval_steps": 500,
7
+ "global_step": 314,
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.9614,
15
+ "eval_loss": 0.11236772686243057,
16
+ "eval_model_preparation_time": 0.0024,
17
+ "eval_runtime": 61.0327,
18
+ "eval_samples_per_second": 81.923,
19
+ "eval_steps_per_second": 10.24,
20
+ "step": 157
21
+ },
22
+ {
23
+ "epoch": 2.0,
24
+ "eval_accuracy": 0.972,
25
+ "eval_loss": 0.07697099447250366,
26
+ "eval_model_preparation_time": 0.0024,
27
+ "eval_runtime": 60.4043,
28
+ "eval_samples_per_second": 82.776,
29
+ "eval_steps_per_second": 10.347,
30
+ "step": 314
31
+ }
32
+ ],
33
+ "logging_steps": 500,
34
+ "max_steps": 314,
35
+ "num_input_tokens_seen": 0,
36
+ "num_train_epochs": 2,
37
+ "save_steps": 500,
38
+ "stateful_callbacks": {
39
+ "TrainerControl": {
40
+ "args": {
41
+ "should_epoch_stop": false,
42
+ "should_evaluate": false,
43
+ "should_log": false,
44
+ "should_save": true,
45
+ "should_training_stop": true
46
+ },
47
+ "attributes": {}
48
+ }
49
+ },
50
+ "total_flos": 8.3755495821312e+17,
51
+ "train_batch_size": 32,
52
+ "trial_name": null,
53
+ "trial_params": null
54
+ }
checkpoint-314/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60bfe4936cb8662967af80740b170b7ee49a77c617cfb4b4d72cb94fb4856548
3
+ size 5304
config.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SiglipForImageClassification"
4
+ ],
5
+ "id2label": {
6
+ "0": "Female \u2640",
7
+ "1": "Male \u2642"
8
+ },
9
+ "initializer_factor": 1.0,
10
+ "label2id": {
11
+ "Female \u2640": 0,
12
+ "Male \u2642": 1
13
+ },
14
+ "model_type": "siglip",
15
+ "problem_type": "single_label_classification",
16
+ "text_config": {
17
+ "attention_dropout": 0.0,
18
+ "hidden_act": "gelu_pytorch_tanh",
19
+ "hidden_size": 768,
20
+ "intermediate_size": 3072,
21
+ "layer_norm_eps": 1e-06,
22
+ "max_position_embeddings": 64,
23
+ "model_type": "siglip_text_model",
24
+ "num_attention_heads": 12,
25
+ "num_hidden_layers": 12,
26
+ "projection_size": 768,
27
+ "torch_dtype": "float32",
28
+ "vocab_size": 256000
29
+ },
30
+ "torch_dtype": "float32",
31
+ "transformers_version": "4.51.0.dev0",
32
+ "vision_config": {
33
+ "attention_dropout": 0.0,
34
+ "hidden_act": "gelu_pytorch_tanh",
35
+ "hidden_size": 768,
36
+ "image_size": 224,
37
+ "intermediate_size": 3072,
38
+ "layer_norm_eps": 1e-06,
39
+ "model_type": "siglip_vision_model",
40
+ "num_attention_heads": 12,
41
+ "num_channels": 3,
42
+ "num_hidden_layers": 12,
43
+ "patch_size": 16,
44
+ "torch_dtype": "float32"
45
+ }
46
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:672245c638f4bced0d3d2c6dc3b4c8e1b936ad88259e443dfbe919a677d3bae3
3
+ size 371567992
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:60bfe4936cb8662967af80740b170b7ee49a77c617cfb4b4d72cb94fb4856548
3
+ size 5304