Update my_model/tabs/run_inference.py
Browse files
my_model/tabs/run_inference.py
CHANGED
@@ -29,16 +29,6 @@ sample_images = ["Files/sample1.jpg", "Files/sample2.jpg", "Files/sample3.jpg",
|
|
29 |
|
30 |
|
31 |
|
32 |
-
def analyze_image(image, model):
|
33 |
-
|
34 |
-
img = copy.deepcopy(image) # we dont wanna apply changes to the original image
|
35 |
-
caption = model.get_caption(img)
|
36 |
-
image_with_boxes, detected_objects_str = model.detect_objects(img)
|
37 |
-
st.text("I am ready, let's talk!")
|
38 |
-
free_gpu_resources()
|
39 |
-
|
40 |
-
return caption, detected_objects_str, image_with_boxes
|
41 |
-
|
42 |
|
43 |
def image_qa_app(kbvqa):
|
44 |
# Display sample images as clickable thumbnails
|
@@ -82,16 +72,6 @@ def image_qa_app(kbvqa):
|
|
82 |
|
83 |
|
84 |
|
85 |
-
def process_new_image(image_key, image, kbvqa):
|
86 |
-
"""Process a new image and update the session state."""
|
87 |
-
if image_key not in st.session_state['images_data']:
|
88 |
-
st.session_state['images_data'][image_key] = {
|
89 |
-
'image': image,
|
90 |
-
'caption': '',
|
91 |
-
'detected_objects_str': '',
|
92 |
-
'qa_history': [],
|
93 |
-
'analysis_done': False
|
94 |
-
}
|
95 |
|
96 |
def run_inference():
|
97 |
|
@@ -116,8 +96,8 @@ def run_inference():
|
|
116 |
state_manager.reload_detection_model()
|
117 |
st.success("Model reloaded with updated settings and ready for inference.")
|
118 |
|
119 |
-
|
120 |
-
|
121 |
|
122 |
|
123 |
st.write(st.session_state.kbvqa.all_models_loaded)
|
@@ -126,17 +106,4 @@ def run_inference():
|
|
126 |
st.write('Model is not ready yet, will be updated later.')
|
127 |
|
128 |
|
129 |
-
def display_model_settings():
|
130 |
-
st.write("### Current Model Settings:")
|
131 |
-
st.table(pd.DataFrame(st.session_state['model_settings'], index=[0]))
|
132 |
-
|
133 |
-
def display_session_state():
|
134 |
-
st.write("### Current Session State:")
|
135 |
-
# Convert session state to a list of dictionaries, each representing a row
|
136 |
-
data = [{'Key': key, 'Value': str(value)} for key, value in st.session_state.items()]
|
137 |
-
# Create a DataFrame from the list
|
138 |
-
df = pd.DataFrame(data)
|
139 |
-
st.table(df)
|
140 |
-
|
141 |
-
|
142 |
|
|
|
29 |
|
30 |
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
def image_qa_app(kbvqa):
|
34 |
# Display sample images as clickable thumbnails
|
|
|
72 |
|
73 |
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
def run_inference():
|
77 |
|
|
|
96 |
state_manager.reload_detection_model()
|
97 |
st.success("Model reloaded with updated settings and ready for inference.")
|
98 |
|
99 |
+
if state_manager.is_model_loaded() and st.session_state.kbvqa.all_models_loaded:
|
100 |
+
image_qa_app(state_manager.get_model())
|
101 |
|
102 |
|
103 |
st.write(st.session_state.kbvqa.all_models_loaded)
|
|
|
106 |
st.write('Model is not ready yet, will be updated later.')
|
107 |
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|