Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -68,29 +68,30 @@ def image_qa_app(kbvqa_model):
|
|
| 68 |
for idx, sample_image_path in enumerate(sample_images):
|
| 69 |
with cols[idx]:
|
| 70 |
image = Image.open(sample_image_path)
|
| 71 |
-
st.image(image, use_column_width=True)
|
| 72 |
if st.button(f'Select Sample Image {idx + 1}', key=f'sample_{idx}'):
|
| 73 |
-
st.session_state['current_image'] =
|
| 74 |
st.session_state['qa_history'] = []
|
| 75 |
st.session_state['analysis_done'] = False
|
| 76 |
st.session_state['answer_in_progress'] = False
|
| 77 |
-
|
| 78 |
|
| 79 |
uploaded_image = st.file_uploader("Or upload an Image", type=["png", "jpg", "jpeg"])
|
| 80 |
-
|
| 81 |
if uploaded_image is not None:
|
| 82 |
-
st.session_state['current_image'] =
|
| 83 |
st.session_state['qa_history'] = []
|
| 84 |
st.session_state['analysis_done'] = False
|
| 85 |
st.session_state['answer_in_progress'] = False
|
| 86 |
|
| 87 |
# Display the image if it's in the session state
|
| 88 |
-
if 'current_image' in st.session_state:
|
| 89 |
-
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
else:
|
| 92 |
-
st.write("image
|
| 93 |
-
|
| 94 |
|
| 95 |
|
| 96 |
|
|
|
|
| 68 |
for idx, sample_image_path in enumerate(sample_images):
|
| 69 |
with cols[idx]:
|
| 70 |
image = Image.open(sample_image_path)
|
|
|
|
| 71 |
if st.button(f'Select Sample Image {idx + 1}', key=f'sample_{idx}'):
|
| 72 |
+
st.session_state['current_image'] = sample_image_path
|
| 73 |
st.session_state['qa_history'] = []
|
| 74 |
st.session_state['analysis_done'] = False
|
| 75 |
st.session_state['answer_in_progress'] = False
|
|
|
|
| 76 |
|
| 77 |
uploaded_image = st.file_uploader("Or upload an Image", type=["png", "jpg", "jpeg"])
|
|
|
|
| 78 |
if uploaded_image is not None:
|
| 79 |
+
st.session_state['current_image'] = uploaded_image
|
| 80 |
st.session_state['qa_history'] = []
|
| 81 |
st.session_state['analysis_done'] = False
|
| 82 |
st.session_state['answer_in_progress'] = False
|
| 83 |
|
| 84 |
# Display the image if it's in the session state
|
| 85 |
+
if 'current_image' in st.session_state and st.session_state['current_image'] is not None:
|
| 86 |
+
if isinstance(st.session_state['current_image'], str):
|
| 87 |
+
# If it's a file path from sample images
|
| 88 |
+
image_to_display = Image.open(st.session_state['current_image'])
|
| 89 |
+
else:
|
| 90 |
+
# If it's an uploaded file
|
| 91 |
+
image_to_display = Image.open(st.session_state['current_image'])
|
| 92 |
+
st.image(image_to_display, use_column_width=True)
|
| 93 |
else:
|
| 94 |
+
st.write("No image selected or uploaded.")
|
|
|
|
| 95 |
|
| 96 |
|
| 97 |
|