Nuno-Tome commited on
Commit
98c6d70
·
1 Parent(s): 56ec5ce

feat: iniciar repositório com base em projeto de classificação de imagens

Browse files

* Estrutura inicial criada a partir de simple_image_classifier
* Reutilização de lógica base para classificação de imagens com modelos pré-treinados
* Estabelece fundação para desenvolvimento do projeto

---

feat: initialise repository based on image classifier project

* Initial structure created from simple_image_classifier
* Reuses base logic for image classification with pre-trained models
* Establishes foundation for project development

.vscode/settings.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "workbench.colorCustomizations": {
3
+ "activityBar.activeBackground": "#65c89b",
4
+ "activityBar.background": "#65c89b",
5
+ "activityBar.foreground": "#15202b",
6
+ "activityBar.inactiveForeground": "#15202b99",
7
+ "activityBarBadge.background": "#945bc4",
8
+ "activityBarBadge.foreground": "#e7e7e7",
9
+ "commandCenter.border": "#15202b99",
10
+ "sash.hoverBorder": "#65c89b",
11
+ "statusBar.background": "#42b883",
12
+ "statusBar.foreground": "#15202b",
13
+ "statusBarItem.hoverBackground": "#359268",
14
+ "statusBarItem.remoteBackground": "#42b883",
15
+ "statusBarItem.remoteForeground": "#15202b",
16
+ "titleBar.activeBackground": "#42b883",
17
+ "titleBar.activeForeground": "#15202b",
18
+ "titleBar.inactiveBackground": "#42b88399",
19
+ "titleBar.inactiveForeground": "#15202b99"
20
+ },
21
+ "peacock.color": "#42b883"
22
+ }
README.md CHANGED
@@ -1,13 +1,13 @@
1
  ---
2
  title: Compared Image Classifier
3
- emoji: 🌍
4
- colorFrom: gray
5
- colorTo: blue
6
- sdk: gradio
7
- sdk_version: 6.11.0
8
  app_file: app.py
9
  pinned: false
10
- license: mit
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
  title: Compared Image Classifier
3
+ emoji: 🤑
4
+ colorFrom: purple
5
+ colorTo: indigo
6
+ sdk: streamlit
7
+ sdk_version: 1.31.0
8
  app_file: app.py
9
  pinned: false
10
+ short_description: compare different image classifier models
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ from PIL import Image
4
+
5
+ MODEL_1 = "google/vit-base-patch16-224"
6
+ MIN_ACEPTABLE_SCORE = 0.1
7
+ MAX_N_LABELS = 5
8
+ MODEL_2 = "nateraw/vit-age-classifier"
9
+ MODELS = [
10
+ "-- General Image Classification --",
11
+ "google/vit-base-patch16-224",
12
+ "microsoft/resnet-50",
13
+ "microsoft/resnet-18",
14
+ "microsoft/resnet-34",
15
+ "microsoft/resnet-101",
16
+ "microsoft/resnet-152",
17
+ "microsoft/swin-tiny-patch4-window7-224",
18
+ "microsoft/swinv2-base-patch4-window16-256",
19
+ "microsoft/beit-base-patch16-224-pt22k-ft22k",
20
+ "facebook/convnext-large-224",
21
+ "facebook/convnext-base-224-22k-1k",
22
+ "facebook/convnext-tiny-224",
23
+ "nvidia/mit-b0",
24
+ "timm/resnet50.a1_in1k",
25
+ "timm/tf_efficientnetv2_s.in21k",
26
+ "timm/convnext_tiny.fb_in22k",
27
+ "vit-base-patch16-224-in21k",
28
+ "facebook/deit-base-distilled-patch16-224 << new >>",
29
+ "WinKawaks/vit-tiny-patch16-224 << new >>",
30
+
31
+ "-- Age Classification --",
32
+ "nateraw/vit-age-classifier",
33
+
34
+ "-- NSFW Detection --",
35
+ "Falconsai/nsfw_image_detection",
36
+ "LukeJacob2023/nsfw-image-detector",
37
+ "carbon225/vit-base-patch16-224-hentai",
38
+ "Marqo/nsfw-image-detection-384 << new >>",
39
+
40
+ "-- Aesthetic/Art Classification --",
41
+ "cafeai/cafe_aesthetic",
42
+ "shadowlilac/aesthetic-shadow",
43
+ "pixai-labs/pixai-tagger-v0.9 << new >>",
44
+
45
+ "-- Face/Emotion Classification --",
46
+ "trpakov/vit-face-expression",
47
+ "RickyIG/emotion_face_image_classification",
48
+ "rizvandwiki/gender-classification",
49
+
50
+ "-- Food Classification --",
51
+ "nateraw/food",
52
+ "BinhQuocNguyen/food-recognition-model << new >>",
53
+
54
+ "-- Medical/Dermatology --",
55
+ "google/derm-foundation << new >>",
56
+ "google/cxr-foundation << new >>",
57
+ "Anwarkh1/Skin_Cancer-Image_Classification << new >>",
58
+
59
+ "-- AI vs Human Detection --",
60
+ "Ateeqq/ai-vs-human-image-detector << new >>",
61
+ "umm-maybe/AI-image-detector << new >>",
62
+
63
+ "-- Deepfake Detection --",
64
+ "not-lain/deepfake",
65
+
66
+ "-- Anime/Manga Classification --",
67
+ #"Readidno/anime.mili << new >>", # Not working - missing model_type
68
+
69
+ "-- Human Activity Recognition --",
70
+ "DunnBC22/vit-base-patch16-224-in21k_Human_Activity_Recognition",
71
+
72
+ "-- Clothing/Fashion --",
73
+ "aalonso-developer/vit-base-patch16-224-in21k-clothing-classifier",
74
+
75
+ "-- Real Estate --",
76
+ "andupets/real-estate-image-classification",
77
+
78
+ "-- Satellite/Remote Sensing --",
79
+ "FatihC/swin-tiny-patch4-window7-224-finetuned-eurosat-watermark",
80
+
81
+ "-- Car Classification --",
82
+ "lamnt2008/car_brands_classification << new >>",
83
+
84
+ "-- Document Classification --",
85
+ "docling-project/DocumentFigureClassifier-v2.5 << new >>",
86
+
87
+ "-- EfficientNet (timm) --",
88
+ "timm/efficientnet_b0.ra_in1k << new >>",
89
+ "timm/mobilenetv3_large_100.ra_in1k",
90
+ "timm/mobilenetv3_small_100.lamb_in1k << new >>",
91
+
92
+ "-- Experimental/Future --",
93
+ "#q-future/one-align",
94
+ ]
95
+
96
+ def classify(image, model):
97
+ model_name = model.replace(" << new >>", "")
98
+ classifier = pipeline("image-classification", model=model_name)
99
+ result= classifier(image)
100
+ return result
101
+
102
+ def save_result(result):
103
+ st.write("In the future, this function will save the result in a database.")
104
+
105
+ def print_result(result):
106
+
107
+ comulative_discarded_score = 0
108
+ for i in range(len(result)):
109
+ if result[i]['score'] < MIN_ACEPTABLE_SCORE:
110
+ comulative_discarded_score += result[i]['score']
111
+ else:
112
+ st.write(result[i]['label'])
113
+ st.progress(result[i]['score'])
114
+ st.write(result[i]['score'])
115
+
116
+ st.write(f"comulative_discarded_score:")
117
+ st.progress(comulative_discarded_score)
118
+ st.write(comulative_discarded_score)
119
+
120
+
121
+
122
+ def main():
123
+ st.title("Image Classification")
124
+ st.write("This is a simple web app to test and compare different image classifier models using Hugging Face's image-classification pipeline.")
125
+ st.markdown(":white_check_mark: **:green[22 new models added!]** - Including Medical, AI vs Human detection, Anime classification and more.")
126
+ st.write("From time to time more models will be added to the list. If you want to add a model, please open an issue on the GitHub repository.")
127
+ st.write("If you like this project, please consider liking it or buying me a coffee. It will help me to keep working on this and other projects. Thank you!")
128
+
129
+ # Buy me a Coffee Setup
130
+ bmc_link = "https://www.buymeacoffee.com/nuno.tome"
131
+ # image_url = "https://helloimjessa.files.wordpress.com/2021/06/bmc-button.png?w=150" # Image URL
132
+ image_url = "https://i.giphy.com/RETzc1mj7HpZPuNf3e.webp" # Image URL
133
+
134
+ image_size = "150px" # Image size
135
+ #image_link_markdown = f"<img src='{image_url}' width='25%'>"
136
+ image_link_markdown = f"[![Buy Me a Coffee]({image_url})]({bmc_link})"
137
+
138
+ #image_link_markdown = f"[![Buy Me a Coffee]({image_url})]({bmc_link})" # Create a clickable image link
139
+
140
+ st.markdown(image_link_markdown, unsafe_allow_html=True) # Display the image link
141
+ # Buy me a Coffee Setup
142
+
143
+ #st.markdown("<img src='https://helloimjessa.files.wordpress.com/2021/06/bmc-button.png?w=1024' width='15%'>", unsafe_allow_html=True)
144
+
145
+ input_image = st.file_uploader("Upload Image")
146
+ shosen_model = st.selectbox("Select the model to use", MODELS)
147
+
148
+
149
+ if input_image is not None:
150
+ image_to_classify = Image.open(input_image)
151
+ st.image(image_to_classify, caption="Uploaded Image")
152
+ if st.button("Classify"):
153
+ image_to_classify = Image.open(input_image)
154
+ classification_obj1 =[]
155
+ #avable_models = st.selectbox
156
+
157
+ classification_result = classify(image_to_classify, shosen_model)
158
+ classification_obj1.append(classification_result)
159
+ print_result(classification_result)
160
+ save_result(classification_result)
161
+
162
+
163
+ if __name__ == "__main__":
164
+ main()
contexto.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Descrição
2
+
3
+ Esta aplicação é apenas uma demostração para o hugging face comparado varios classificadores de imagens
huggingface.co-spaces-Nunt-simple_image_classifier.url ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ [{000214A0-0000-0000-C000-000000000046}]
2
+ Prop3=19,11
3
+ [InternetShortcut]
4
+ IDList=
5
+ URL=https://huggingface.co/spaces/Nunt/simple_image_classifier
image/bmc.gif ADDED
image/bmc.webp ADDED
moldel_log,txt ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 2024-02-03 ------------------------------------------------------------------
2
+ In error:
3
+ #NOT OK "microsoft/beit-base-patch16-224-pt22k-ft22k", #Classifição geral
4
+ #NOT OK "timm/vit_large_patch14_clip_224.openai_ft_in12k_in1k", #Classifição geral
5
+ #NOT OK "timm/vit_base_patch16_224_in21k", #Classifição geral escolhida pelo copilot
6
+ #NOT OK "microsoft/resnet-50-kinetics-400", #Classifição geral escolhida pelo copilot
7
+
8
+ ----
9
+
10
+ "microsoft/beit-base-patch16-224-pt22k-ft22k", #Classifição geral
11
+ ok
12
+ TODO: reintroduce to test
13
+
14
+ "timm/vit_large_patch14_clip_224.openai_ft_in12k_in1k", #Classifição geral
15
+ ok
16
+ other layout
17
+ TODO: adapt
18
+
19
+ "timm/vit_base_patch16_224_in21k", #Classifição geral escolhida pelo copilot
20
+ off-line
21
+
22
+ "microsoft/resnet-50-kinetics-400", #Classifição geral escolhida pelo copilot
23
+ off-line
24
+
25
+ ---
26
+
27
+ model/del/microsoft_resnet-50-kinetics-400
28
+ model/add/microsoft_beit-base-patch16-224-pt22k-ft22k
29
+ "microsoft/beit-base-patch16-224-pt22k-ft22k", #Classifição geral
30
+
31
+ ---
32
+
33
+ models to add
34
+ Laxhar/anime_aesthetic_variant
35
+ in error but test
36
+
37
+ apple/ml-aim.git
38
+ sem tester online
39
+
40
+ new:"
41
+
42
+ "
43
+ "
44
+
45
+
46
+ https://huggingface.co/timm/fastvit_ma36.apple_dist_in1k
47
+
48
+
49
+
50
+ fancyfeast/joytag
51
+ in error but test
52
+
53
+ test:
54
+ https://huggingface.co/spaces/teowu/OneScorer
55
+
56
+ can have use
57
+ https://huggingface.co/spaces/AnnasBlackHat/Image-Similarity
58
+ https://huggingface.co/spaces/omerXfaruq/FindYourTwins
59
+ https://huggingface.co/spaces/Woleek/image-based-soundtrack-generation
60
+ https://huggingface.co/chbh7051/vit-final-driver-drowsiness-detection
61
+
62
+
63
+ colonoscopia
64
+
65
+ https://huggingface.co/mrm8488/vit-base-patch16-224_finetuned-kvasirv2-colonoscopy
66
+ huggingface.co/DunnBC22/vit-base-patch16-224-in21k_covid_19_ct_scans
nunt-simple-image-classifier.hf.space.url ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ [{000214A0-0000-0000-C000-000000000046}]
2
+ Prop3=19,11
3
+ [InternetShortcut]
4
+ IDList=
5
+ URL=https://nunt-simple-image-classifier.hf.space/
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ torch
3
+ transformers
simple_image_classifier.code-workspace ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": "."
5
+ }
6
+ ],
7
+ "settings": {
8
+ "workbench.colorCustomizations": {
9
+ "activityBar.activeBackground": "#6ce19f",
10
+ "activityBar.background": "#6ce19f",
11
+ "activityBar.foreground": "#15202b",
12
+ "activityBar.inactiveForeground": "#15202b99",
13
+ "activityBarBadge.background": "#9760df",
14
+ "activityBarBadge.foreground": "#e7e7e7",
15
+ "commandCenter.border": "#15202b99",
16
+ "sash.hoverBorder": "#6ce19f",
17
+ "statusBar.background": "#42d883",
18
+ "statusBar.foreground": "#15202b",
19
+ "statusBarItem.hoverBackground": "#28bf69",
20
+ "statusBarItem.remoteBackground": "#42d883",
21
+ "statusBarItem.remoteForeground": "#15202b",
22
+ "titleBar.activeBackground": "#42d883",
23
+ "titleBar.activeForeground": "#15202b",
24
+ "titleBar.inactiveBackground": "#42d88399",
25
+ "titleBar.inactiveForeground": "#15202b99"
26
+ },
27
+ "peacock.color": "#42d883"
28
+ }
29
+ }