Dannel commited on
Commit
3fe034c
1 Parent(s): f3fecd7

Upload 10 files

Browse files
.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,12 +1,13 @@
1
- ---
2
- title: Gender
3
- emoji:
4
- colorFrom: gray
5
- colorTo: gray
6
- sdk: gradio
7
- sdk_version: 4.37.2
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
+ ---
2
+ title: Simple 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 CHANGED
@@ -1,116 +1,116 @@
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
- "google/vit-base-patch16-224", #Classifição geral
11
- "nateraw/vit-age-classifier", #Classifição de idade
12
- "microsoft/resnet-50", #Classifição geral
13
- "Falconsai/nsfw_image_detection", #Classifição NSFW
14
- "cafeai/cafe_aesthetic", #Classifição de estética
15
- "microsoft/resnet-18", #Classifição geral
16
- "microsoft/resnet-34", #Classifição geral escolhida pelo copilot
17
- "microsoft/resnet-101", #Classifição geral escolhida pelo copilot
18
- "microsoft/resnet-152", #Classifição geral escolhida pelo copilot
19
- "microsoft/swin-tiny-patch4-window7-224",#Classifição geral
20
- "-- Reinstated on testing--",
21
- "microsoft/beit-base-patch16-224-pt22k-ft22k", #Classifição geral
22
- "-- New --",
23
- "-- Still in the testing process --",
24
- "facebook/convnext-large-224", #Classifição geral
25
- "timm/resnet50.a1_in1k", #Classifição geral
26
- "timm/mobilenetv3_large_100.ra_in1k", #Classifição geral
27
- "trpakov/vit-face-expression", #Classifição de expressão facial
28
- "rizvandwiki/gender-classification", #Classifição de gênero
29
- "#q-future/one-align", #Classifição geral
30
- "LukeJacob2023/nsfw-image-detector", #Classifição NSFW
31
- "vit-base-patch16-224-in21k", #Classifição geral
32
- "not-lain/deepfake", #Classifição deepfake
33
- "carbon225/vit-base-patch16-224-hentai", #Classifição hentai
34
- "facebook/convnext-base-224-22k-1k", #Classifição geral
35
- "facebook/convnext-large-224", #Classifição geral
36
- "facebook/convnext-tiny-224",#Classifição geral
37
- "nvidia/mit-b0", #Classifição geral
38
- "microsoft/resnet-18", #Classifição geral
39
- "microsoft/swinv2-base-patch4-window16-256", #Classifição geral
40
- "andupets/real-estate-image-classification", #Classifição de imóveis
41
- "timm/tf_efficientnetv2_s.in21k", #Classifição geral
42
- "timm/convnext_tiny.fb_in22k",
43
- "DunnBC22/vit-base-patch16-224-in21k_Human_Activity_Recognition", #Classifição de atividade humana
44
- "FatihC/swin-tiny-patch4-window7-224-finetuned-eurosat-watermark", #Classifição geral
45
- "aalonso-developer/vit-base-patch16-224-in21k-clothing-classifier", #Classifição de roupas
46
- "RickyIG/emotion_face_image_classification", #Classifição de emoções
47
- "shadowlilac/aesthetic-shadow" #Classifição de estética
48
- ]
49
-
50
- def classify(image, model):
51
- classifier = pipeline("image-classification", model=model)
52
- result= classifier(image)
53
- return result
54
-
55
- def save_result(result):
56
- st.write("In the future, this function will save the result in a database.")
57
-
58
- def print_result(result):
59
-
60
- comulative_discarded_score = 0
61
- for i in range(len(result)):
62
- if result[i]['score'] < MIN_ACEPTABLE_SCORE:
63
- comulative_discarded_score += result[i]['score']
64
- else:
65
- st.write(result[i]['label'])
66
- st.progress(result[i]['score'])
67
- st.write(result[i]['score'])
68
-
69
- st.write(f"comulative_discarded_score:")
70
- st.progress(comulative_discarded_score)
71
- st.write(comulative_discarded_score)
72
-
73
-
74
-
75
- def main():
76
- st.title("Image Classification")
77
- st.write("This is a simple web app to test and compare different image classifier models using Hugging Face's image-classification pipeline.")
78
- 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.")
79
- 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!")
80
-
81
- # Buy me a Coffee Setup
82
- bmc_link = "https://www.buymeacoffee.com/nuno.tome"
83
- # image_url = "https://helloimjessa.files.wordpress.com/2021/06/bmc-button.png?w=150" # Image URL
84
- image_url = "https://i.giphy.com/RETzc1mj7HpZPuNf3e.webp" # Image URL
85
-
86
- image_size = "150px" # Image size
87
- #image_link_markdown = f"<img src='{image_url}' width='25%'>"
88
- image_link_markdown = f"[![Buy Me a Coffee]({image_url})]({bmc_link})"
89
-
90
- #image_link_markdown = f"[![Buy Me a Coffee]({image_url})]({bmc_link})" # Create a clickable image link
91
-
92
- st.markdown(image_link_markdown, unsafe_allow_html=True) # Display the image link
93
- # Buy me a Coffee Setup
94
-
95
- #st.markdown("<img src='https://helloimjessa.files.wordpress.com/2021/06/bmc-button.png?w=1024' width='15%'>", unsafe_allow_html=True)
96
-
97
- input_image = st.file_uploader("Upload Image")
98
- shosen_model = st.selectbox("Select the model to use", MODELS)
99
-
100
-
101
- if input_image is not None:
102
- image_to_classify = Image.open(input_image)
103
- st.image(image_to_classify, caption="Uploaded Image")
104
- if st.button("Classify"):
105
- image_to_classify = Image.open(input_image)
106
- classification_obj1 =[]
107
- #avable_models = st.selectbox
108
-
109
- classification_result = classify(image_to_classify, shosen_model)
110
- classification_obj1.append(classification_result)
111
- print_result(classification_result)
112
- save_result(classification_result)
113
-
114
-
115
- if __name__ == "__main__":
116
  main()
 
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
+ "google/vit-base-patch16-224", #Classifição geral
11
+ "nateraw/vit-age-classifier", #Classifição de idade
12
+ "microsoft/resnet-50", #Classifição geral
13
+ "Falconsai/nsfw_image_detection", #Classifição NSFW
14
+ "cafeai/cafe_aesthetic", #Classifição de estética
15
+ "microsoft/resnet-18", #Classifição geral
16
+ "microsoft/resnet-34", #Classifição geral escolhida pelo copilot
17
+ "microsoft/resnet-101", #Classifição geral escolhida pelo copilot
18
+ "microsoft/resnet-152", #Classifição geral escolhida pelo copilot
19
+ "microsoft/swin-tiny-patch4-window7-224",#Classifição geral
20
+ "-- Reinstated on testing--",
21
+ "microsoft/beit-base-patch16-224-pt22k-ft22k", #Classifição geral
22
+ "-- New --",
23
+ "-- Still in the testing process --",
24
+ "facebook/convnext-large-224", #Classifição geral
25
+ "timm/resnet50.a1_in1k", #Classifição geral
26
+ "timm/mobilenetv3_large_100.ra_in1k", #Classifição geral
27
+ "trpakov/vit-face-expression", #Classifição de expressão facial
28
+ "rizvandwiki/gender-classification", #Classifição de gênero
29
+ "#q-future/one-align", #Classifição geral
30
+ "LukeJacob2023/nsfw-image-detector", #Classifição NSFW
31
+ "vit-base-patch16-224-in21k", #Classifição geral
32
+ "not-lain/deepfake", #Classifição deepfake
33
+ "carbon225/vit-base-patch16-224-hentai", #Classifição hentai
34
+ "facebook/convnext-base-224-22k-1k", #Classifição geral
35
+ "facebook/convnext-large-224", #Classifição geral
36
+ "facebook/convnext-tiny-224",#Classifição geral
37
+ "nvidia/mit-b0", #Classifição geral
38
+ "microsoft/resnet-18", #Classifição geral
39
+ "microsoft/swinv2-base-patch4-window16-256", #Classifição geral
40
+ "andupets/real-estate-image-classification", #Classifição de imóveis
41
+ "timm/tf_efficientnetv2_s.in21k", #Classifição geral
42
+ "timm/convnext_tiny.fb_in22k",
43
+ "DunnBC22/vit-base-patch16-224-in21k_Human_Activity_Recognition", #Classifição de atividade humana
44
+ "FatihC/swin-tiny-patch4-window7-224-finetuned-eurosat-watermark", #Classifição geral
45
+ "aalonso-developer/vit-base-patch16-224-in21k-clothing-classifier", #Classifição de roupas
46
+ "RickyIG/emotion_face_image_classification", #Classifição de emoções
47
+ "shadowlilac/aesthetic-shadow" #Classifição de estética
48
+ ]
49
+
50
+ def classify(image, model):
51
+ classifier = pipeline("image-classification", model=model)
52
+ result= classifier(image)
53
+ return result
54
+
55
+ def save_result(result):
56
+ st.write("In the future, this function will save the result in a database.")
57
+
58
+ def print_result(result):
59
+
60
+ comulative_discarded_score = 0
61
+ for i in range(len(result)):
62
+ if result[i]['score'] < MIN_ACEPTABLE_SCORE:
63
+ comulative_discarded_score += result[i]['score']
64
+ else:
65
+ st.write(result[i]['label'])
66
+ st.progress(result[i]['score'])
67
+ st.write(result[i]['score'])
68
+
69
+ st.write(f"comulative_discarded_score:")
70
+ st.progress(comulative_discarded_score)
71
+ st.write(comulative_discarded_score)
72
+
73
+
74
+
75
+ def main():
76
+ st.title("Image Classification")
77
+ st.write("This is a simple web app to test and compare different image classifier models using Hugging Face's image-classification pipeline.")
78
+ 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.")
79
+ 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!")
80
+
81
+ # Buy me a Coffee Setup
82
+ bmc_link = "https://www.buymeacoffee.com/nuno.tome"
83
+ # image_url = "https://helloimjessa.files.wordpress.com/2021/06/bmc-button.png?w=150" # Image URL
84
+ image_url = "https://i.giphy.com/RETzc1mj7HpZPuNf3e.webp" # Image URL
85
+
86
+ image_size = "150px" # Image size
87
+ #image_link_markdown = f"<img src='{image_url}' width='25%'>"
88
+ image_link_markdown = f"[![Buy Me a Coffee]({image_url})]({bmc_link})"
89
+
90
+ #image_link_markdown = f"[![Buy Me a Coffee]({image_url})]({bmc_link})" # Create a clickable image link
91
+
92
+ st.markdown(image_link_markdown, unsafe_allow_html=True) # Display the image link
93
+ # Buy me a Coffee Setup
94
+
95
+ #st.markdown("<img src='https://helloimjessa.files.wordpress.com/2021/06/bmc-button.png?w=1024' width='15%'>", unsafe_allow_html=True)
96
+
97
+ input_image = st.file_uploader("Upload Image")
98
+ shosen_model = st.selectbox("Select the model to use", MODELS)
99
+
100
+
101
+ if input_image is not None:
102
+ image_to_classify = Image.open(input_image)
103
+ st.image(image_to_classify, caption="Uploaded Image")
104
+ if st.button("Classify"):
105
+ image_to_classify = Image.open(input_image)
106
+ classification_obj1 =[]
107
+ #avable_models = st.selectbox
108
+
109
+ classification_result = classify(image_to_classify, shosen_model)
110
+ classification_obj1.append(classification_result)
111
+ print_result(classification_result)
112
+ save_result(classification_result)
113
+
114
+
115
+ if __name__ == "__main__":
116
  main()
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 CHANGED
@@ -1,3 +1,3 @@
1
- streamlit
2
- torch
3
  transformers
 
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
+ }