Update my_model/utilities/state_manager.py
Browse files
my_model/utilities/state_manager.py
CHANGED
|
@@ -7,7 +7,7 @@ from my_model.KBVQA import KBVQA, prepare_kbvqa_model
|
|
| 7 |
|
| 8 |
class StateManager:
|
| 9 |
def __init__(self):
|
| 10 |
-
|
| 11 |
|
| 12 |
def initialize_state(self):
|
| 13 |
if 'images_data' not in st.session_state:
|
|
@@ -46,15 +46,15 @@ class StateManager:
|
|
| 46 |
df = pd.DataFrame(data)
|
| 47 |
st.table(df)
|
| 48 |
|
| 49 |
-
def load_model(self
|
| 50 |
"""Load the KBVQA model with specified settings."""
|
| 51 |
try:
|
| 52 |
free_gpu_resources()
|
| 53 |
-
st.text("Loading the model, please wait...")
|
| 54 |
-
st.session_state['kbvqa'] = prepare_kbvqa_model(detection_model)
|
| 55 |
-
st.session_state['kbvqa'].detection_confidence = confidence_level
|
| 56 |
-
self.update_model_settings(detection_model, confidence_level)
|
| 57 |
-
st.
|
| 58 |
free_gpu_resources()
|
| 59 |
except Exception as e:
|
| 60 |
st.error(f"Error loading model: {e}")
|
|
|
|
| 7 |
|
| 8 |
class StateManager:
|
| 9 |
def __init__(self):
|
| 10 |
+
# self.initialize_state()
|
| 11 |
|
| 12 |
def initialize_state(self):
|
| 13 |
if 'images_data' not in st.session_state:
|
|
|
|
| 46 |
df = pd.DataFrame(data)
|
| 47 |
st.table(df)
|
| 48 |
|
| 49 |
+
def load_model(self):
|
| 50 |
"""Load the KBVQA model with specified settings."""
|
| 51 |
try:
|
| 52 |
free_gpu_resources()
|
| 53 |
+
st.text("Loading the model, this should take no more than a few minutes, please wait...")
|
| 54 |
+
st.session_state['kbvqa'] = prepare_kbvqa_model(st.state_session.detection_model)
|
| 55 |
+
st.session_state['kbvqa'].detection_confidence = st.state_session.confidence_level
|
| 56 |
+
#self.update_model_settings(detection_model, confidence_level)
|
| 57 |
+
st.text("Model is ready for inference.")
|
| 58 |
free_gpu_resources()
|
| 59 |
except Exception as e:
|
| 60 |
st.error(f"Error loading model: {e}")
|