Spaces:
Running
Running
no message
Browse files
app.py
CHANGED
|
@@ -14,8 +14,9 @@ DATASETS = [
|
|
| 14 |
]
|
| 15 |
MAX_N_LABELS = 5
|
| 16 |
|
| 17 |
-
|
| 18 |
-
def
|
|
|
|
| 19 |
|
| 20 |
for image in dataset:
|
| 21 |
st("Image classification: ", image['file'])
|
|
@@ -32,28 +33,31 @@ def old_classify_images(classifier_model, dataset_to_classify):
|
|
| 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",
|
| 43 |
-
st.write("
|
| 44 |
|
| 45 |
#modle instance
|
| 46 |
classifier_pipeline = pipeline('image-classification', model=chosen_model_name)
|
| 47 |
-
|
| 48 |
-
|
| 49 |
#classification
|
| 50 |
-
classification_result =
|
| 51 |
st.write(classification_result)
|
| 52 |
-
st.write("
|
| 53 |
-
|
| 54 |
-
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
|
| 59 |
|
|
@@ -77,15 +81,13 @@ def main():
|
|
| 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("
|
| 84 |
-
classification_result
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
st.write("# FLAG 6")
|
| 88 |
-
st.write(classification_array)
|
| 89 |
|
| 90 |
if __name__ == "__main__":
|
| 91 |
main()
|
|
|
|
| 14 |
]
|
| 15 |
MAX_N_LABELS = 5
|
| 16 |
|
| 17 |
+
#(image_object, classifier_pipeline)
|
| 18 |
+
#def classify_one_image(classifier_model, dataset_to_classify):
|
| 19 |
+
def classify_one_image(classifier_model, dataset_to_classify):
|
| 20 |
|
| 21 |
for image in dataset:
|
| 22 |
st("Image classification: ", image['file'])
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
def classify_full_dataset(shosen_dataset_name, chosen_model_name):
|
| 36 |
+
image_count = 0
|
| 37 |
+
|
| 38 |
#dataset
|
| 39 |
dataset = load_dataset(shosen_dataset_name,"testedata_readme")
|
|
|
|
|
|
|
| 40 |
#Image teste load
|
| 41 |
image_object = dataset['pasta'][0]["image"]
|
| 42 |
+
st.image(image_object, caption="Uploaded Image", height=300)
|
| 43 |
+
st.write("### FLAG 3")
|
| 44 |
|
| 45 |
#modle instance
|
| 46 |
classifier_pipeline = pipeline('image-classification', model=chosen_model_name)
|
| 47 |
+
st.write("### FLAG 4")
|
| 48 |
+
|
| 49 |
#classification
|
| 50 |
+
classification_result = classify_one_image(image_object, classifier_pipeline)
|
| 51 |
st.write(classification_result)
|
| 52 |
+
st.write("### FLAG 5")
|
| 53 |
+
#classification_array.append(classification_result)
|
|
|
|
| 54 |
|
| 55 |
+
#save classification
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
image_count += 1
|
| 59 |
+
|
| 60 |
+
return image_count
|
| 61 |
|
| 62 |
|
| 63 |
|
|
|
|
| 81 |
#image_object = dataset['pasta'][0]
|
| 82 |
if chosen_model_name is not None and shosen_dataset_name is not None:
|
| 83 |
if st.button("Classify images"):
|
| 84 |
+
|
| 85 |
+
#classification_array =[]
|
| 86 |
+
classification_result = classify_full_dataset(shosen_dataset_name, chosen_model_name)
|
| 87 |
+
st.write(f"Classification result: {classification_result}")
|
| 88 |
+
#classification_array.append(classification_result)
|
| 89 |
+
#st.write("# FLAG 6")
|
| 90 |
+
#st.write(classification_array)
|
|
|
|
|
|
|
| 91 |
|
| 92 |
if __name__ == "__main__":
|
| 93 |
main()
|