Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -69,10 +69,12 @@ def image_qa_app(kbvqa):
|
|
| 69 |
image_data['detected_objects_str'] = detected_objects_str
|
| 70 |
image_data['analysis_done'] = True
|
| 71 |
|
|
|
|
|
|
|
|
|
|
| 72 |
if image_data['analysis_done']:
|
| 73 |
-
question = st.text_input("Ask a question about this image:", key=f'question_{image_key}')
|
| 74 |
if st.button('Get Answer', key=f'answer_{image_key}'):
|
| 75 |
-
qa_history = image_data.get('qa_history', [])
|
| 76 |
if question not in [q for q, _ in qa_history]:
|
| 77 |
answer = answer_question(image_data['caption'], image_data['detected_objects_str'], question, kbvqa)
|
| 78 |
qa_history.append((question, answer))
|
|
@@ -80,9 +82,9 @@ def image_qa_app(kbvqa):
|
|
| 80 |
else:
|
| 81 |
st.info("This question has already been asked.")
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
|
| 87 |
|
| 88 |
def process_new_image(image_key, image, kbvqa):
|
|
|
|
| 69 |
image_data['detected_objects_str'] = detected_objects_str
|
| 70 |
image_data['analysis_done'] = True
|
| 71 |
|
| 72 |
+
# Initialize qa_history for each image
|
| 73 |
+
qa_history = image_data.get('qa_history', [])
|
| 74 |
+
|
| 75 |
if image_data['analysis_done']:
|
| 76 |
+
question = st.text_input(f"Ask a question about this image ({image_key[-11:]}):", key=f'question_{image_key}')
|
| 77 |
if st.button('Get Answer', key=f'answer_{image_key}'):
|
|
|
|
| 78 |
if question not in [q for q, _ in qa_history]:
|
| 79 |
answer = answer_question(image_data['caption'], image_data['detected_objects_str'], question, kbvqa)
|
| 80 |
qa_history.append((question, answer))
|
|
|
|
| 82 |
else:
|
| 83 |
st.info("This question has already been asked.")
|
| 84 |
|
| 85 |
+
# Display Q&A history for each image
|
| 86 |
+
for q, a in qa_history:
|
| 87 |
+
st.text(f"Q: {q}\nA: {a}\n")
|
| 88 |
|
| 89 |
|
| 90 |
def process_new_image(image_key, image, kbvqa):
|