Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,15 +38,16 @@ elif option == "Image Classification":
|
|
| 38 |
|
| 39 |
uploaded_file = st.file_uploader("Choose an image file", type=["jpg", "jpeg", "png"])
|
| 40 |
text = st.text_area("Enter possible class names (comma-separated)")
|
| 41 |
-
if
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
| 50 |
|
| 51 |
|
| 52 |
else:
|
|
|
|
| 38 |
|
| 39 |
uploaded_file = st.file_uploader("Choose an image file", type=["jpg", "jpeg", "png"])
|
| 40 |
text = st.text_area("Enter possible class names (comma-separated)")
|
| 41 |
+
if st.button("Submit"):
|
| 42 |
+
if uploaded_file is not None and text:
|
| 43 |
+
candidate_labels = [t.strip() for t in text.split(',')]
|
| 44 |
+
image = Image.open(uploaded_file)
|
| 45 |
+
st.image(image, caption="Uploaded Image", use_column_width=True)
|
| 46 |
+
classification_result = imgpipe(image, candidate_labels)
|
| 47 |
+
for result in classification_result:
|
| 48 |
+
st.write(f"Label: {result['label']}, Score: {result['score']}")
|
| 49 |
+
else:
|
| 50 |
+
st.write("Please upload an image file and enter class names.")
|
| 51 |
|
| 52 |
|
| 53 |
else:
|