m7mdal7aj commited on
Commit
db80e27
1 Parent(s): bda1cda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -75,8 +75,9 @@ def image_qa_app(kbvqa):
75
  if uploaded_image is not None:
76
  image = Image.open(uploaded_image)
77
  st.session_state['current_image'] = image
78
- st.session_state['processed_image'] = copy.deepcopy(image) # Create a copy for processing
79
  st.session_state['qa_history'] = []
 
80
 
81
  # Display the current image (unaltered)
82
  if st.session_state.get('current_image') is not None:
@@ -85,19 +86,17 @@ def image_qa_app(kbvqa):
85
  # Question input and processing
86
  question = st.text_input("Ask a question about this image:")
87
  if st.button('Get Answer'):
88
- # Use the processed image for object detection and other processing
89
  processed_image = st.session_state.get('processed_image')
90
  if processed_image:
91
- # Perform object detection or other processing on processed_image
92
- # For example: processed_image = perform_object_detection(processed_image)
93
  answer = answer_question(processed_image, question, model=kbvqa)
94
  st.session_state['qa_history'].append((question, answer))
 
95
 
96
  # Display all Q&A
97
  for q, a in st.session_state['qa_history']:
98
  st.text(f"Q: {q}\nA: {a}\n")
99
 
100
- # Update the processed image in session state
101
  st.session_state['processed_image'] = processed_image
102
 
103
 
 
75
  if uploaded_image is not None:
76
  image = Image.open(uploaded_image)
77
  st.session_state['current_image'] = image
78
+ st.session_state['processed_image'] = copy.deepcopy(image)
79
  st.session_state['qa_history'] = []
80
+ print("Image uploaded and processed image set.")
81
 
82
  # Display the current image (unaltered)
83
  if st.session_state.get('current_image') is not None:
 
86
  # Question input and processing
87
  question = st.text_input("Ask a question about this image:")
88
  if st.button('Get Answer'):
 
89
  processed_image = st.session_state.get('processed_image')
90
  if processed_image:
91
+ print("Processing image for question:", question)
 
92
  answer = answer_question(processed_image, question, model=kbvqa)
93
  st.session_state['qa_history'].append((question, answer))
94
+ print("Answer generated:", answer)
95
 
96
  # Display all Q&A
97
  for q, a in st.session_state['qa_history']:
98
  st.text(f"Q: {q}\nA: {a}\n")
99
 
 
100
  st.session_state['processed_image'] = processed_image
101
 
102