m7mdal7aj commited on
Commit
753c201
1 Parent(s): df50fb0

Update my_model/utilities/state_manager.py

Browse files
Files changed (1) hide show
  1. my_model/utilities/state_manager.py +14 -0
my_model/utilities/state_manager.py CHANGED
@@ -1,5 +1,6 @@
1
  import pandas as pd
2
  import streamlit as st
 
3
 
4
 
5
  class StateManager:
@@ -39,6 +40,19 @@ class StateManager:
39
  df = pd.DataFrame(data)
40
  st.table(df)
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  def get_model(self):
43
  """Retrieve the KBVQA model from the session state."""
44
  return st.session_state.get('kbvqa', None)
 
1
  import pandas as pd
2
  import streamlit as st
3
+ from my_model.gen_utilities import free_gpu_resources
4
 
5
 
6
  class StateManager:
 
40
  df = pd.DataFrame(data)
41
  st.table(df)
42
 
43
+ def load_model(self, detection_model, confidence_level):
44
+ """Load the KBVQA model with specified settings."""
45
+ try:
46
+ free_gpu_resources()
47
+ st.text("Loading the model, please wait...")
48
+ st.session_state['kbvqa'] = prepare_kbvqa_model(detection_model)
49
+ st.session_state['kbvqa'].detection_confidence = confidence_level
50
+ self.update_model_settings(detection_model, confidence_level)
51
+ st.write("Model is ready for inference.")
52
+ free_gpu_resources()
53
+ except Exception as e:
54
+ st.error(f"Error loading model: {e}")
55
+
56
  def get_model(self):
57
  """Retrieve the KBVQA model from the session state."""
58
  return st.session_state.get('kbvqa', None)