Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,8 +6,11 @@ from PIL import Image
|
|
| 6 |
|
| 7 |
|
| 8 |
# Initialization
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
if 'upload_choice' not in st.session_state:
|
| 10 |
-
result = None
|
| 11 |
st.session_state['upload_choice'] = 'file_up'
|
| 12 |
|
| 13 |
def change_state():
|
|
@@ -69,10 +72,12 @@ model_loaded.load_state_dict(torch.load(model_path, map_location='cpu'))
|
|
| 69 |
# Set the model to evaluation mode
|
| 70 |
model_loaded.eval()
|
| 71 |
|
| 72 |
-
if
|
| 73 |
-
|
|
|
|
|
|
|
| 74 |
|
| 75 |
-
if
|
| 76 |
if result == 'Bird':
|
| 77 |
st.write(":bird:" + " That's a Bird " + ":bird:")
|
| 78 |
else:
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
# Initialization
|
| 9 |
+
if 'generate_result' not in st.session_state:
|
| 10 |
+
st.session_state['generate_result'] = 0
|
| 11 |
+
if 'show_result' not in st.session_state:
|
| 12 |
+
st.session_state['show_result'] = 0
|
| 13 |
if 'upload_choice' not in st.session_state:
|
|
|
|
| 14 |
st.session_state['upload_choice'] = 'file_up'
|
| 15 |
|
| 16 |
def change_state():
|
|
|
|
| 72 |
# Set the model to evaluation mode
|
| 73 |
model_loaded.eval()
|
| 74 |
|
| 75 |
+
if st.session_state['generate_result'] != 0:
|
| 76 |
+
if img is not None:
|
| 77 |
+
result = predict_image(image_path=img, model=model_loaded)
|
| 78 |
+
st.session_state['generate_result'] = 0
|
| 79 |
|
| 80 |
+
if st.session_state['show_result'] != 0:
|
| 81 |
if result == 'Bird':
|
| 82 |
st.write(":bird:" + " That's a Bird " + ":bird:")
|
| 83 |
else:
|