Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -62,7 +62,21 @@ def main():
|
|
62 |
# ... (rest of the code remains unchanged)
|
63 |
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
|
68 |
|
|
|
62 |
# ... (rest of the code remains unchanged)
|
63 |
|
64 |
|
65 |
+
elif choice == "Upload Image":
|
66 |
+
st.subheader("Upload Your Own Images")
|
67 |
+
if "model" not in st.session_state:
|
68 |
+
st.warning("Please train the model first.")
|
69 |
+
else:
|
70 |
+
uploaded_files = st.file_uploader("Choose images", type=["jpg", "jpeg", "png"], accept_multiple_files=True)
|
71 |
|
72 |
+
if uploaded_files:
|
73 |
+
for img in uploaded_files:
|
74 |
+
img = PILImage.create(img)
|
75 |
+
label, _, probs = st.session_state.model.predict(img)
|
76 |
+
|
77 |
+
st.image(img, caption=f"This is a {label}.")
|
78 |
+
st.write(f"{label_a}: {probs[1].item():.6f}")
|
79 |
+
st.write(f"{label_b}: {probs[0].item():.6f}")
|
80 |
|
81 |
|
82 |
|