Spaces:
Sleeping
Sleeping
no message
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ DATASETS = [
|
|
15 |
MAX_N_LABELS = 5
|
16 |
|
17 |
|
18 |
-
def
|
19 |
|
20 |
for image in dataset:
|
21 |
st("Image classification: ", image['file'])
|
@@ -29,62 +29,63 @@ def classify_images(classifier_model, dataset_to_classify):
|
|
29 |
'''
|
30 |
return "done"
|
31 |
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
return "done"
|
34 |
|
|
|
|
|
|
|
35 |
def main():
|
36 |
st.title("Bulk Image Classification")
|
37 |
st.markdown("This app uses several 🤗 models to classify images stored in 🤗 datasets.")
|
38 |
st.write("Soon we will have a dataset template")
|
39 |
|
40 |
-
|
41 |
-
'''
|
42 |
-
Model
|
43 |
-
'''
|
44 |
chosen_model_name = st.selectbox("Select the model to use", MODELS, index=0)
|
45 |
if chosen_model_name is not None:
|
46 |
st.write("You selected", chosen_model_name)
|
47 |
|
48 |
-
|
49 |
-
Dataset
|
50 |
-
'''
|
51 |
shosen_dataset_name = st.selectbox("Select the dataset to use", DATASETS, index=0)
|
52 |
if shosen_dataset_name is not None:
|
53 |
st.write("You selected", shosen_dataset_name)
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
'''
|
58 |
-
click to classify
|
59 |
-
image_object = dataset['pasta'][0]
|
60 |
-
'''
|
61 |
if chosen_model_name is not None and shosen_dataset_name is not None:
|
62 |
if st.button("Classify images"):
|
63 |
|
64 |
-
|
65 |
-
st.write("# FLAG 1")
|
66 |
-
|
67 |
-
dataset = load_dataset(shosen_dataset_name,"testedata_readme")
|
68 |
-
st.write("# FLAG 2")
|
69 |
-
|
70 |
-
#Igame
|
71 |
-
image_object = dataset['pasta'][0]["image"]
|
72 |
-
st.image(image_object, caption="Uploaded Image", use_column_width=True)
|
73 |
-
st.write("# FLAG 3")
|
74 |
|
75 |
-
#
|
76 |
-
|
77 |
-
#classifier_pipeline = pipeline('image-classification', model="nateraw/vit-age-classifier", device=0)
|
78 |
-
st.write("# FLAG 4")
|
79 |
|
80 |
-
|
81 |
-
classification_result = classify(image_object, classifier_pipeline)
|
82 |
-
st.write(classification_result)
|
83 |
-
st.write("# FLAG 5")
|
84 |
-
classification_obj1.append(classification_result)
|
85 |
st.write("# FLAG 6")
|
86 |
-
st.write(
|
87 |
-
|
88 |
|
89 |
if __name__ == "__main__":
|
90 |
main()
|
|
|
15 |
MAX_N_LABELS = 5
|
16 |
|
17 |
|
18 |
+
def old_classify_images(classifier_model, dataset_to_classify):
|
19 |
|
20 |
for image in dataset:
|
21 |
st("Image classification: ", image['file'])
|
|
|
29 |
'''
|
30 |
return "done"
|
31 |
|
32 |
+
|
33 |
+
|
34 |
+
def classify_full_dataset(shosen_dataset_name, chosen_model_name):
|
35 |
+
|
36 |
+
#dataset
|
37 |
+
dataset = load_dataset(shosen_dataset_name,"testedata_readme")
|
38 |
+
st.write("# FLAG 2")
|
39 |
+
|
40 |
+
#Image teste load
|
41 |
+
image_object = dataset['pasta'][0]["image"]
|
42 |
+
st.image(image_object, caption="Uploaded Image", use_column_width=True)
|
43 |
+
st.write("# FLAG 3")
|
44 |
+
|
45 |
+
#modle instance
|
46 |
+
classifier_pipeline = pipeline('image-classification', model=chosen_model_name)
|
47 |
+
#classifier_pipeline = pipeline('image-classification', model="nateraw/vit-age-classifier", device=0)
|
48 |
+
st.write("# FLAG 4")
|
49 |
+
#classification
|
50 |
+
classification_result = classify(image_object, classifier_pipeline)
|
51 |
+
st.write(classification_result)
|
52 |
+
st.write("# FLAG 5")
|
53 |
+
|
54 |
+
|
55 |
+
|
56 |
return "done"
|
57 |
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
def main():
|
62 |
st.title("Bulk Image Classification")
|
63 |
st.markdown("This app uses several 🤗 models to classify images stored in 🤗 datasets.")
|
64 |
st.write("Soon we will have a dataset template")
|
65 |
|
66 |
+
#Model
|
|
|
|
|
|
|
67 |
chosen_model_name = st.selectbox("Select the model to use", MODELS, index=0)
|
68 |
if chosen_model_name is not None:
|
69 |
st.write("You selected", chosen_model_name)
|
70 |
|
71 |
+
#Dataset
|
|
|
|
|
72 |
shosen_dataset_name = st.selectbox("Select the dataset to use", DATASETS, index=0)
|
73 |
if shosen_dataset_name is not None:
|
74 |
st.write("You selected", shosen_dataset_name)
|
75 |
|
76 |
+
#click to classify
|
77 |
+
#image_object = dataset['pasta'][0]
|
|
|
|
|
|
|
|
|
78 |
if chosen_model_name is not None and shosen_dataset_name is not None:
|
79 |
if st.button("Classify images"):
|
80 |
|
81 |
+
classification_array =[]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
+
st.write("# FLAG 1")
|
84 |
+
classification_result = classify(shosen_dataset_name, chosen_model_name)
|
|
|
|
|
85 |
|
86 |
+
classification_array.append(classification_result)
|
|
|
|
|
|
|
|
|
87 |
st.write("# FLAG 6")
|
88 |
+
st.write(classification_array)
|
|
|
89 |
|
90 |
if __name__ == "__main__":
|
91 |
main()
|