Amal Vinoy commited on
Commit
875807e
·
verified ·
1 Parent(s): 46f72cf

Upload 8 files

Browse files
README.md ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ pipeline_tag: image-text-to-text
4
+ license: apache-2.0
5
+ datasets:
6
+ - joshuachou/SkinCAP
7
+ - HemanthKumarK/SKINgpt
8
+ language:
9
+ - en
10
+ tags:
11
+ - biology
12
+ - skin
13
+ - skin disease
14
+ - cancer
15
+ - medical
16
+ ---
17
+ # Model Card for PaliGemma Dermatology Model
18
+
19
+ ## Model Details
20
+
21
+ ### Model Description
22
+
23
+ This model, based on the PaliGemma-3B architecture, has been fine-tuned for dermatology-related image and text processing tasks. The model is designed to assist in the identification of various skin conditions using a combination of image analysis and natural language processing.
24
+
25
+
26
+ - **Developed by:** Bruce_Wayne
27
+ - **Model type:** vision model
28
+ - **Finetuned from model:** https://huggingface.co/google/paligemma-3b-pt-224
29
+ - **LoRa Adaptors used:** Yes
30
+ - **Intended use:** Medical image analysis, specifically for dermatology
31
+ **
32
+ ### please let me know how the model works -->https://forms.gle/cBA6apSevTyiEbp46
33
+ ### Thank you
34
+ ## Uses
35
+ ### Direct Use
36
+
37
+ The model can be directly used for analyzing dermatology images, providing insights into potential skin conditions.
38
+
39
+
40
+ ## Bias, Risks, and Limitations
41
+
42
+ **Skin Tone Bias:** The model may have been trained on a dataset that does not adequately represent all skin tones, potentially leading to biased results.
43
+ **Geographic Bias:** The model's performance may vary depending on the prevalence of certain conditions in different geographic regions.
44
+
45
+ ## How to Get Started with the Model
46
+
47
+ ```python
48
+
49
+ import torch
50
+ from transformers import AutoProcessor, PaliGemmaForConditionalGeneration
51
+ from PIL import Image
52
+
53
+ # Load the model and processor
54
+ model_id = "brucewayne0459/paligemma_derm"
55
+ processor = AutoProcessor.from_pretrained(model_id)
56
+ model = PaliGemmaForConditionalGeneration.from_pretrained(model_id, device_map={"": 0})
57
+ model.eval()
58
+
59
+ # Load a sample image and text input
60
+ input_text = "Identify the skin condition?"
61
+ input_image_path = " Replace with your actual image path"
62
+ input_image = Image.open(input_image_path).convert("RGB")
63
+
64
+ # Process the input
65
+ inputs = processor(text=input_text, images=input_image, return_tensors="pt", padding="longest").to("cuda" if torch.cuda.is_available() else "cpu")
66
+
67
+ # Set the maximum length for generation
68
+ max_new_tokens = 50
69
+
70
+ # Run inference
71
+ with torch.no_grad():
72
+ outputs = model.generate(**inputs, max_new_tokens=max_new_tokens)
73
+
74
+ # Decode the output
75
+ decoded_output = processor.decode(outputs[0], skip_special_tokens=True)
76
+ print("Model Output:", decoded_output)
77
+ ```
78
+ ## Training Details
79
+
80
+ ### Training Data
81
+
82
+ The model was fine-tuned on a dataset of dermatological images combined with disease names
83
+
84
+ ### Training Procedure
85
+
86
+ The model was fine-tuned using LoRA (Low-Rank Adaptation) for more efficient training. Mixed precision (bfloat16) was used to speed up training and reduce memory usage.
87
+
88
+ #### Training Hyperparameters
89
+
90
+ - **Training regime:** Mixed precision (bfloat16)
91
+ - **Epochs:** 10
92
+ - **Learning rate:** 2e-5
93
+ - **Batch size:** 6
94
+ - **Gradient accumulation steps:** 4
95
+
96
+
97
+ ## Evaluation
98
+
99
+ ### Testing Data, Factors & Metrics
100
+
101
+ #### Testing Data
102
+
103
+ The model was evaluated on a separate validation set of dermatological images and Disease Names, distinct from the training data.
104
+
105
+ #### Metrics
106
+ - **Validation Loss:** The loss was tracked throughout the training process to evaluate model performance.
107
+ - **Accuracy:** The primary metric for assessing model predictions.
108
+ ### Results
109
+
110
+ The model achieved a final validation loss of approximately 0.2214, indicating reasonable performance in predicting skin conditions based on the dataset used.
111
+
112
+ #### Summary
113
+
114
+
115
+ ## Environmental Impact
116
+
117
+
118
+ - **Hardware Type:** 1 x L4 GPU
119
+ - **Hours used:** ~22 HOURS
120
+ - **Cloud Provider:** LIGHTNING AI
121
+ - **Compute Region:** USA
122
+ - **Carbon Emitted:** 0.9 kg eq. CO2
123
+
124
+ ## Technical Specifications
125
+
126
+ ### Model Architecture and Objective
127
+
128
+ - **Architecture:** Vision-Language model based on PaliGemma-3B
129
+ - **Objective:** To classify and diagnose dermatological conditions from images and text
130
+
131
+ ### Compute Infrastructure
132
+
133
+ #### Hardware
134
+
135
+ - **GPU:** 1xL4 GPU
136
+ ## Model Card Authors
137
+ Bruce_Wayne
config.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "google/paligemma-3b-pt-224",
3
+ "architectures": [
4
+ "PaliGemmaForConditionalGeneration"
5
+ ],
6
+ "bos_token_id": 2,
7
+ "eos_token_id": 1,
8
+ "hidden_size": 2048,
9
+ "image_token_index": 257152,
10
+ "model_type": "paligemma",
11
+ "pad_token_id": 0,
12
+ "projection_dim": 2048,
13
+ "text_config": {
14
+ "hidden_size": 2048,
15
+ "intermediate_size": 16384,
16
+ "model_type": "gemma",
17
+ "num_attention_heads": 8,
18
+ "num_hidden_layers": 18,
19
+ "num_image_tokens": 256,
20
+ "num_key_value_heads": 1,
21
+ "torch_dtype": "float32",
22
+ "vocab_size": 257216
23
+ },
24
+ "torch_dtype": "float32",
25
+ "transformers_version": "4.45.0.dev0",
26
+ "vision_config": {
27
+ "hidden_size": 1152,
28
+ "intermediate_size": 4304,
29
+ "model_type": "siglip_vision_model",
30
+ "num_attention_heads": 16,
31
+ "num_hidden_layers": 27,
32
+ "num_image_tokens": 256,
33
+ "patch_size": 14,
34
+ "projection_dim": 2048,
35
+ "projector_hidden_act": "gelu_fast",
36
+ "vision_use_head": false
37
+ }
38
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 2,
4
+ "eos_token_id": 1,
5
+ "pad_token_id": 0,
6
+ "transformers_version": "4.45.0.dev0"
7
+ }
gitattributes ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
model-00002-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5cfdf65953f036f1789d3f9136758620442f1a64de31372b90204466578b8c16
3
+ size 4999820608
preprocessor_config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_seq_length": 256,
13
+ "image_std": [
14
+ 0.5,
15
+ 0.5,
16
+ 0.5
17
+ ],
18
+ "processor_class": "PaliGemmaProcessor",
19
+ "resample": 3,
20
+ "rescale_factor": 0.00392156862745098,
21
+ "size": {
22
+ "height": 224,
23
+ "width": 224
24
+ }
25
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ {
4
+ "content": "<image>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false
9
+ }
10
+ ],
11
+ "bos_token": {
12
+ "content": "<bos>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false
17
+ },
18
+ "eos_token": {
19
+ "content": "<eos>",
20
+ "lstrip": false,
21
+ "normalized": false,
22
+ "rstrip": false,
23
+ "single_word": false
24
+ },
25
+ "pad_token": {
26
+ "content": "<pad>",
27
+ "lstrip": false,
28
+ "normalized": false,
29
+ "rstrip": false,
30
+ "single_word": false
31
+ },
32
+ "unk_token": {
33
+ "content": "<unk>",
34
+ "lstrip": false,
35
+ "normalized": false,
36
+ "rstrip": false,
37
+ "single_word": false
38
+ }
39
+ }
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff