Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
from fastai.vision.all import *
|
3 |
import shutil
|
@@ -51,12 +52,6 @@ def main():
|
|
51 |
st.session_state.model = learn # Save the model to session state
|
52 |
st.success("Model trained successfully!")
|
53 |
|
54 |
-
# ... (rest of the code remains unchanged)
|
55 |
-
|
56 |
-
# Run the Streamlit app
|
57 |
-
if __name__ == "__main__":
|
58 |
-
main()
|
59 |
-
|
60 |
elif choice == "Upload Image":
|
61 |
st.subheader("Upload Your Own Images")
|
62 |
if "model" not in st.session_state:
|
@@ -73,6 +68,21 @@ if __name__ == "__main__":
|
|
73 |
st.write(f"{label_a}: {probs[1].item():.6f}")
|
74 |
st.write(f"{label_b}: {probs[0].item():.6f}")
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
elif choice == "Test Random Images":
|
77 |
st.subheader("Test Using Images in Dataset")
|
78 |
if "model" not in st.session_state:
|
|
|
1 |
+
# streamlit_app.py
|
2 |
import streamlit as st
|
3 |
from fastai.vision.all import *
|
4 |
import shutil
|
|
|
52 |
st.session_state.model = learn # Save the model to session state
|
53 |
st.success("Model trained successfully!")
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
elif choice == "Upload Image":
|
56 |
st.subheader("Upload Your Own Images")
|
57 |
if "model" not in st.session_state:
|
|
|
68 |
st.write(f"{label_a}: {probs[1].item():.6f}")
|
69 |
st.write(f"{label_b}: {probs[0].item():.6f}")
|
70 |
|
71 |
+
# ... (rest of the code remains unchanged)
|
72 |
+
|
73 |
+
# Run the Streamlit app
|
74 |
+
if __name__ == "__main__":
|
75 |
+
main()
|
76 |
+
|
77 |
+
if uploaded_files:
|
78 |
+
for img in uploaded_files:
|
79 |
+
img = PILImage.create(img)
|
80 |
+
label, _, probs = st.session_state.model.predict(img)
|
81 |
+
|
82 |
+
st.image(img, caption=f"This is a {label}.")
|
83 |
+
st.write(f"{label_a}: {probs[1].item():.6f}")
|
84 |
+
st.write(f"{label_b}: {probs[0].item():.6f}")
|
85 |
+
|
86 |
elif choice == "Test Random Images":
|
87 |
st.subheader("Test Using Images in Dataset")
|
88 |
if "model" not in st.session_state:
|