Update app.py
Browse files
app.py
CHANGED
|
@@ -52,7 +52,6 @@ def run_inference():
|
|
| 52 |
image_qa_app(st.session_state['kbvqa'])
|
| 53 |
|
| 54 |
|
| 55 |
-
|
| 56 |
def image_qa_app(kbvqa):
|
| 57 |
# Initialize session state for storing the current image and its Q&A history
|
| 58 |
if 'current_image' not in st.session_state:
|
|
@@ -66,7 +65,8 @@ def image_qa_app(kbvqa):
|
|
| 66 |
for idx, sample_image_path in enumerate(sample_images):
|
| 67 |
with cols[idx]:
|
| 68 |
image = Image.open(sample_image_path)
|
| 69 |
-
|
|
|
|
| 70 |
st.session_state['current_image'] = image
|
| 71 |
st.session_state['qa_history'] = []
|
| 72 |
|
|
@@ -93,7 +93,7 @@ def image_qa_app(kbvqa):
|
|
| 93 |
# Display all Q&A
|
| 94 |
for q, a in st.session_state['qa_history']:
|
| 95 |
st.text(f"Q: {q}\nA: {a}\n")
|
| 96 |
-
|
| 97 |
|
| 98 |
# Main function
|
| 99 |
def main():
|
|
|
|
| 52 |
image_qa_app(st.session_state['kbvqa'])
|
| 53 |
|
| 54 |
|
|
|
|
| 55 |
def image_qa_app(kbvqa):
|
| 56 |
# Initialize session state for storing the current image and its Q&A history
|
| 57 |
if 'current_image' not in st.session_state:
|
|
|
|
| 65 |
for idx, sample_image_path in enumerate(sample_images):
|
| 66 |
with cols[idx]:
|
| 67 |
image = Image.open(sample_image_path)
|
| 68 |
+
# Use button for each image
|
| 69 |
+
if st.button(f'Sample Image {idx + 1}', key=f'sample_{idx}'):
|
| 70 |
st.session_state['current_image'] = image
|
| 71 |
st.session_state['qa_history'] = []
|
| 72 |
|
|
|
|
| 93 |
# Display all Q&A
|
| 94 |
for q, a in st.session_state['qa_history']:
|
| 95 |
st.text(f"Q: {q}\nA: {a}\n")
|
| 96 |
+
|
| 97 |
|
| 98 |
# Main function
|
| 99 |
def main():
|