Spaces:
Running
Running
Update my_model/tabs/run_inference.py
Browse files
my_model/tabs/run_inference.py
CHANGED
@@ -66,8 +66,8 @@ class InferenceRunner(StateManager):
|
|
66 |
if uploaded_image is not None:
|
67 |
self.process_new_image(uploaded_image.name, Image.open(uploaded_image))
|
68 |
|
69 |
-
def display_image_and_analysis(self, image_key, image_data):
|
70 |
-
|
71 |
image_for_display = self.resize_image(image_data['image'], 600)
|
72 |
nested_col21.image(image_for_display, caption=f'Uploaded Image: {image_key[-11:]}')
|
73 |
self.handle_analysis_button(image_key, image_data, nested_col22)
|
@@ -86,6 +86,7 @@ class InferenceRunner(StateManager):
|
|
86 |
self.display_question_answering_interface(image_key, image_data, nested_col22)
|
87 |
|
88 |
def display_question_answering_interface(self, image_key, image_data, nested_col22):
|
|
|
89 |
sample_questions = config.SAMPLE_QUESTIONS.get(image_key, [])
|
90 |
selected_question = nested_col22.selectbox("Select a sample question or type your own:", ["Custom question..."] + sample_questions, key=f'sample_question_{image_key}')
|
91 |
custom_question = nested_col22.text_input("Or ask your own question:", key=f'custom_question_{image_key}')
|
@@ -106,8 +107,11 @@ class InferenceRunner(StateManager):
|
|
106 |
self.display_session_state()
|
107 |
with self.col2:
|
108 |
for image_key, image_data in self.get_images_data().items():
|
109 |
-
with st.container
|
110 |
-
|
|
|
|
|
|
|
111 |
self.handle_question_answering(image_key, image_data, nested_col22)
|
112 |
|
113 |
|
|
|
66 |
if uploaded_image is not None:
|
67 |
self.process_new_image(uploaded_image.name, Image.open(uploaded_image))
|
68 |
|
69 |
+
def display_image_and_analysis(self, image_key, image_data, nested_col21, nested_col22):
|
70 |
+
|
71 |
image_for_display = self.resize_image(image_data['image'], 600)
|
72 |
nested_col21.image(image_for_display, caption=f'Uploaded Image: {image_key[-11:]}')
|
73 |
self.handle_analysis_button(image_key, image_data, nested_col22)
|
|
|
86 |
self.display_question_answering_interface(image_key, image_data, nested_col22)
|
87 |
|
88 |
def display_question_answering_interface(self, image_key, image_data, nested_col22):
|
89 |
+
|
90 |
sample_questions = config.SAMPLE_QUESTIONS.get(image_key, [])
|
91 |
selected_question = nested_col22.selectbox("Select a sample question or type your own:", ["Custom question..."] + sample_questions, key=f'sample_question_{image_key}')
|
92 |
custom_question = nested_col22.text_input("Or ask your own question:", key=f'custom_question_{image_key}')
|
|
|
107 |
self.display_session_state()
|
108 |
with self.col2:
|
109 |
for image_key, image_data in self.get_images_data().items():
|
110 |
+
with st.container:
|
111 |
+
nested_col21, nested_col22 = st.columns([0.65, 0.35])
|
112 |
+
image_for_display = self.resize_image(image_data['image'], 600)
|
113 |
+
nested_col21.image(image_for_display, caption=f'Uploaded Image: {image_key[-11:]}')
|
114 |
+
self.display_image_and_analysis(image_key, image_data, nested_col21, nested_col22)
|
115 |
self.handle_question_answering(image_key, image_data, nested_col22)
|
116 |
|
117 |
|