m7mdal7aj commited on
Commit
6c2141c
·
verified ·
1 Parent(s): 5ed0ddd

Update my_model/KBVQA.py

Browse files
Files changed (1) hide show
  1. my_model/KBVQA.py +24 -23
my_model/KBVQA.py CHANGED
@@ -268,29 +268,30 @@ def prepare_kbvqa_model(only_reload_detection_model: bool = False) -> KBVQA:
268
  kbvqa = KBVQA()
269
  kbvqa.detection_model = st.session_state.detection_model
270
  # Progress bar for model loading
271
- with kbvqa.col1.spinner('Loading model...'):
272
-
273
- if not only_reload_detection_model:
274
- kbvqa.col1.text('this should take no more than a few minutes!')
275
- progress_bar = kbvqa.col1.progress(0)
276
- kbvqa.load_detector(kbvqa.detection_model)
277
- progress_bar.progress(33)
278
- kbvqa.load_caption_model()
279
- free_gpu_resources()
280
- progress_bar.progress(75)
281
- kbvqa.col1.text('Almost there :)')
282
- kbvqa.load_fine_tuned_model()
 
 
 
 
 
 
 
 
 
 
 
283
  free_gpu_resources()
284
- progress_bar.progress(100)
285
- else:
286
- progress_bar = kbvqa.col1.progress(0)
287
- kbvqa.load_detector(kbvqa.detection_model)
288
- progress_bar.progress(100)
289
-
290
- if kbvqa.all_models_loaded:
291
- kbvqa.col1.success('Model loaded successfully and ready for inferecne!')
292
- kbvqa.kbvqa_model.eval()
293
- free_gpu_resources()
294
- return kbvqa
295
 
296
 
 
268
  kbvqa = KBVQA()
269
  kbvqa.detection_model = st.session_state.detection_model
270
  # Progress bar for model loading
271
+ with kbvqa.col1:
272
+ with st.spinner('Loading model...'):
273
+
274
+ if not only_reload_detection_model:
275
+ st.text('this should take no more than a few minutes!')
276
+ progress_bar = st.progress(0)
277
+ kbvqa.load_detector(kbvqa.detection_model)
278
+ progress_bar.progress(33)
279
+ kbvqa.load_caption_model()
280
+ free_gpu_resources()
281
+ progress_bar.progress(75)
282
+ st.text('Almost there :)')
283
+ kbvqa.load_fine_tuned_model()
284
+ free_gpu_resources()
285
+ progress_bar.progress(100)
286
+ else:
287
+ progress_bar = st.progress(0)
288
+ kbvqa.load_detector(kbvqa.detection_model)
289
+ progress_bar.progress(100)
290
+
291
+ if kbvqa.all_models_loaded:
292
+ st.success('Model loaded successfully and ready for inferecne!')
293
+ kbvqa.kbvqa_model.eval()
294
  free_gpu_resources()
295
+ return kbvqa
 
 
 
 
 
 
 
 
 
 
296
 
297