Afsha001 commited on
Commit
4c45c7c
·
verified ·
1 Parent(s): 41b5082

update interface

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -282,7 +282,6 @@ def fuse_captions(cap1: str, cap2: str, qwen_tok, qwen_mod) -> str:
282
  if fused.lower().startswith(prefix.lower()):
283
  fused = fused[len(prefix):].strip()
284
 
285
- # Safety — trim to last complete sentence if still cut off
286
  if fused and not fused.endswith((".", "!", "?")):
287
  last_stop = max(
288
  fused.rfind("."),
@@ -477,17 +476,23 @@ if uploaded_file is not None:
477
  with col_run:
478
  if st.button("Generate Caption", type="primary", use_container_width=True):
479
 
480
- with st.spinner("Loading local models (first run takes 3-4 min)..."):
 
 
 
481
  (
482
  florence_proc, florence_mod,
483
  blip_proc, blip_itm,
484
  qwen_tok, qwen_mod
485
  ) = load_local_models()
486
 
 
 
487
  progress = st.progress(0)
488
  status = st.empty()
489
 
490
  status.info("Step 1/6: Generating captions with Florence-2-Large...")
 
491
  captions = generate_captions_florence(
492
  input_image, florence_proc, florence_mod
493
  )
@@ -536,6 +541,7 @@ if uploaded_file is not None:
536
  st.info(f"2. {best_2}")
537
 
538
  status.info("Step 6/6: Fusing captions with Qwen2.5-1.5B...")
 
539
  final = fuse_captions(best_1, best_2, qwen_tok, qwen_mod)
540
  progress.progress(100)
541
  status.success("Pipeline complete!")
 
282
  if fused.lower().startswith(prefix.lower()):
283
  fused = fused[len(prefix):].strip()
284
 
 
285
  if fused and not fused.endswith((".", "!", "?")):
286
  last_stop = max(
287
  fused.rfind("."),
 
476
  with col_run:
477
  if st.button("Generate Caption", type="primary", use_container_width=True):
478
 
479
+ st.info(" First time? Models are downloading and loading — this takes 3 to 4 minutes only once. After that, every run will be much faster!")
480
+ st.warning(" Please do not refresh or close the page while models are loading.")
481
+
482
+ with st.spinner("⏳ Loading Florence-2, BLIP and Qwen models... Please wait patiently!"):
483
  (
484
  florence_proc, florence_mod,
485
  blip_proc, blip_itm,
486
  qwen_tok, qwen_mod
487
  ) = load_local_models()
488
 
489
+ st.success(" All models loaded successfully! Starting the pipeline now...")
490
+
491
  progress = st.progress(0)
492
  status = st.empty()
493
 
494
  status.info("Step 1/6: Generating captions with Florence-2-Large...")
495
+ st.info(" Florence-2 is reading your image carefully — generating 5 diverse captions. This takes about 20–30 seconds, please hold on!")
496
  captions = generate_captions_florence(
497
  input_image, florence_proc, florence_mod
498
  )
 
541
  st.info(f"2. {best_2}")
542
 
543
  status.info("Step 6/6: Fusing captions with Qwen2.5-1.5B...")
544
+ st.success(" Best captions selected! Now crafting your final detailed caption — please hold on for about 30–60 seconds, it is definitely on the way!")
545
  final = fuse_captions(best_1, best_2, qwen_tok, qwen_mod)
546
  progress.progress(100)
547
  status.success("Pipeline complete!")