Spaces:
Sleeping
Sleeping
Update my_model/tabs/run_inference.py
Browse files
my_model/tabs/run_inference.py
CHANGED
|
@@ -78,6 +78,35 @@ class InferenceRunner(StateManager):
|
|
| 78 |
if st.session_state['settings_changed']:
|
| 79 |
self.col1.warning("Model settings have changed, please reload the model, this will take a second .. ")
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
st.session_state.button_label = "Reload Model" if self.is_model_loaded() and self.settings_changed else "Load Model"
|
| 82 |
|
| 83 |
if st.session_state.method == "Fine-Tuned Model":
|
|
|
|
| 78 |
if st.session_state['settings_changed']:
|
| 79 |
self.col1.warning("Model settings have changed, please reload the model, this will take a second .. ")
|
| 80 |
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
###################################
|
| 87 |
+
for idx, sample_image_path in enumerate(self.sample_images):
|
| 88 |
+
with cols[idx]:
|
| 89 |
+
image = Image.open(sample_image_path)
|
| 90 |
+
image_for_display = copy.deepcopy(image) # resize just for the display control without changing original image
|
| 91 |
+
image_for_display = self.resize_image(image_for_display, 500, 500)
|
| 92 |
+
st.image(image_for_display)
|
| 93 |
+
if st.button(f'Select Sample Image {idx + 1}', key=f'sample_{idx}'):
|
| 94 |
+
self.process_new_image(sample_image_path, image, kbvqa)
|
| 95 |
+
|
| 96 |
+
# Image uploader
|
| 97 |
+
uploaded_image = self.col1.file_uploader("Or upload an Image", type=["png", "jpg", "jpeg"])
|
| 98 |
+
if uploaded_image is not None:
|
| 99 |
+
self.process_new_image(uploaded_image.name, Image.open(uploaded_image), kbvqa)
|
| 100 |
+
############################################
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
|
| 110 |
st.session_state.button_label = "Reload Model" if self.is_model_loaded() and self.settings_changed else "Load Model"
|
| 111 |
|
| 112 |
if st.session_state.method == "Fine-Tuned Model":
|