m7mdal7aj commited on
Commit
fc89ea0
1 Parent(s): c8c3960

Update my_model/tabs/run_inference.py

Browse files
Files changed (1) hide show
  1. my_model/tabs/run_inference.py +10 -9
my_model/tabs/run_inference.py CHANGED
@@ -33,7 +33,7 @@ class InferenceRunner(StateManager):
33
  # Display sample images as clickable thumbnails
34
  self.col1.write("Choose from sample images:")
35
  cols = self.col1.columns(len(self.sample_images))
36
- st.write(st.session_state['loading_in_progress'])
37
  for idx, sample_image_path in enumerate(self.sample_images):
38
  with cols[idx]:
39
  image = Image.open(sample_image_path)
@@ -43,7 +43,7 @@ class InferenceRunner(StateManager):
43
  self.process_new_image(sample_image_path, image, kbvqa)
44
 
45
 
46
- st.write(st.session_state['loading_in_progress'])
47
 
48
 
49
  # Image uploader
@@ -118,7 +118,7 @@ class InferenceRunner(StateManager):
118
  with st.container():
119
  nested_col11, nested_col12 = st.columns([0.5, 0.5])
120
  if nested_col11.button(st.session_state.button_label, on_click=self.disable_widgets, disabled=self.is_widget_disabled):
121
- t1=time.time()
122
  if st.session_state.button_label == "Load Model":
123
  if self.is_model_loaded():
124
  free_gpu_resources()
@@ -131,12 +131,13 @@ class InferenceRunner(StateManager):
131
 
132
  if nested_col12.button("Force Reload", on_click=self.disable_widgets, disabled=self.is_widget_disabled):
133
  force_reload_full_model = True
134
- t1=time.time()
135
 
136
  if load_fine_tuned_model:
 
137
  free_gpu_resources()
138
  self.load_model()
139
-
140
  st.session_state['loading_in_progress'] = False
141
 
142
  elif fine_tuned_model_already_loaded:
@@ -151,9 +152,9 @@ class InferenceRunner(StateManager):
151
 
152
  elif force_reload_full_model:
153
  free_gpu_resources()
154
-
155
  self.force_reload_model()
156
-
157
  st.session_state['loading_in_progress'] = False
158
  st.session_state['model_loaded'] = True
159
 
@@ -163,11 +164,11 @@ class InferenceRunner(StateManager):
163
 
164
 
165
  if self.is_model_loaded():
166
- st.session_state['time_taken_to_load_model'] = time.time()-t1
167
  st.write(f'time is {time.time()-t1}')
168
  free_gpu_resources()
169
  st.session_state['loading_in_progress'] = False
170
  self.image_qa_app(self.get_model())
171
- st.write(st.session_state['loading_in_progress'])
172
 
173
 
 
33
  # Display sample images as clickable thumbnails
34
  self.col1.write("Choose from sample images:")
35
  cols = self.col1.columns(len(self.sample_images))
36
+ st.write('loading in prog?', st.session_state['loading_in_progress'])
37
  for idx, sample_image_path in enumerate(self.sample_images):
38
  with cols[idx]:
39
  image = Image.open(sample_image_path)
 
43
  self.process_new_image(sample_image_path, image, kbvqa)
44
 
45
 
46
+ st.write('loading in prog?',st.session_state['loading_in_progress'])
47
 
48
 
49
  # Image uploader
 
118
  with st.container():
119
  nested_col11, nested_col12 = st.columns([0.5, 0.5])
120
  if nested_col11.button(st.session_state.button_label, on_click=self.disable_widgets, disabled=self.is_widget_disabled):
121
+
122
  if st.session_state.button_label == "Load Model":
123
  if self.is_model_loaded():
124
  free_gpu_resources()
 
131
 
132
  if nested_col12.button("Force Reload", on_click=self.disable_widgets, disabled=self.is_widget_disabled):
133
  force_reload_full_model = True
134
+
135
 
136
  if load_fine_tuned_model:
137
+ t1=time.time()
138
  free_gpu_resources()
139
  self.load_model()
140
+ st.session_state['time_taken_to_load_model'] = time.time()-t1
141
  st.session_state['loading_in_progress'] = False
142
 
143
  elif fine_tuned_model_already_loaded:
 
152
 
153
  elif force_reload_full_model:
154
  free_gpu_resources()
155
+ t1=time.time()
156
  self.force_reload_model()
157
+ st.session_state['time_taken_to_load_model'] = time.time()-t1
158
  st.session_state['loading_in_progress'] = False
159
  st.session_state['model_loaded'] = True
160
 
 
164
 
165
 
166
  if self.is_model_loaded():
167
+
168
  st.write(f'time is {time.time()-t1}')
169
  free_gpu_resources()
170
  st.session_state['loading_in_progress'] = False
171
  self.image_qa_app(self.get_model())
172
+ st.write('load success', 'loading in prog?', st.session_state['loading_in_progress'])
173
 
174