Update my_model/tabs/run_inference.py
Browse files
my_model/tabs/run_inference.py
CHANGED
@@ -73,7 +73,10 @@ class InferenceRunner(StateManager):
|
|
73 |
for q, a in qa_history:
|
74 |
nested_col22.text(f"Q: {q}\nA: {a}\n")
|
75 |
|
|
|
|
|
76 |
|
|
|
77 |
def run_inference(self):
|
78 |
self.set_up_widgets()
|
79 |
st.session_state['settings_changed'] = self.has_state_changed()
|
@@ -89,21 +92,37 @@ class InferenceRunner(StateManager):
|
|
89 |
with st.container():
|
90 |
nested_col11, nested_col12 = st.columns([0.5, 0.5])
|
91 |
if nested_col11.button(st.session_state.button_label):
|
|
|
92 |
if st.session_state.button_label == "Load Model":
|
|
|
93 |
if self.is_model_loaded():
|
94 |
free_gpu_resources()
|
95 |
-
|
96 |
else:
|
97 |
-
|
98 |
-
self.load_model()
|
99 |
else:
|
100 |
-
|
101 |
-
|
102 |
if nested_col12.button("Force Reload"):
|
103 |
-
|
104 |
|
105 |
if self.is_model_loaded() and st.session_state.kbvqa.all_models_loaded:
|
106 |
free_gpu_resources()
|
107 |
self.image_qa_app(self.get_model())
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
self.col1.warning(f'Model using {st.session_state.method} is not deployed yet, will be ready later.')
|
|
|
73 |
for q, a in qa_history:
|
74 |
nested_col22.text(f"Q: {q}\nA: {a}\n")
|
75 |
|
76 |
+
def display_message(self, message, warning=False, write=False, text=False):
|
77 |
+
pass
|
78 |
|
79 |
+
|
80 |
def run_inference(self):
|
81 |
self.set_up_widgets()
|
82 |
st.session_state['settings_changed'] = self.has_state_changed()
|
|
|
92 |
with st.container():
|
93 |
nested_col11, nested_col12 = st.columns([0.5, 0.5])
|
94 |
if nested_col11.button(st.session_state.button_label):
|
95 |
+
|
96 |
if st.session_state.button_label == "Load Model":
|
97 |
+
st.session_state['load_button_clicked'] = True
|
98 |
if self.is_model_loaded():
|
99 |
free_gpu_resources()
|
100 |
+
fine_tuned_model_already_loaded = True
|
101 |
else:
|
102 |
+
load_fine_tuned_model = True
|
|
|
103 |
else:
|
104 |
+
reload_detection_model = True
|
105 |
+
|
106 |
if nested_col12.button("Force Reload"):
|
107 |
+
force_reload_full_model = True
|
108 |
|
109 |
if self.is_model_loaded() and st.session_state.kbvqa.all_models_loaded:
|
110 |
free_gpu_resources()
|
111 |
self.image_qa_app(self.get_model())
|
112 |
+
|
113 |
+
elif load_fine_tuned_model:
|
114 |
+
free_gpu_resources()
|
115 |
+
self.load_model()
|
116 |
+
|
117 |
+
elif fine_tuned_model_already_loaded:
|
118 |
+
self.col1.text("Model already loaded and no settings were changed:)")
|
119 |
+
|
120 |
+
elif reload_detection_model:
|
121 |
+
free_gpu_resources()
|
122 |
+
|
123 |
+
self.reload_detection_model()
|
124 |
+
elif force_reload_full_model:
|
125 |
+
self.force_reload_model()
|
126 |
+
|
127 |
+
elif st.session_state.method == "In-Context Learning (n-shots)":
|
128 |
self.col1.warning(f'Model using {st.session_state.method} is not deployed yet, will be ready later.')
|