Y Phung Nguyen commited on
Commit
faa95c5
Β·
1 Parent(s): 4f99918

Upd models loader #6 and UI model loader display

Browse files
Files changed (2) hide show
  1. config.py +4 -2
  2. ui.py +13 -18
config.py CHANGED
@@ -54,8 +54,8 @@ DESCRIPTION = """
54
  <p>πŸ“„ <strong>Document RAG:</strong> Answer based on uploaded medical documents</p>
55
  <p>🌐 <strong>Web Search:</strong> Fetch knowledge from reliable online medical resources</p>
56
  <p>🌍 <strong>Multi-language:</strong> Automatic translation for non-English queries</p>
57
- <p>Tips: Customise configurations, system prompt to see where the magic happens!</p>
58
- <p>Note: Case GPU aborted errors, please select another model or try again later!</p>
59
  </center>
60
  """
61
  CSS = """
@@ -144,6 +144,8 @@ CSS = """
144
  font-weight: 500;
145
  background-color: #f5f5f5;
146
  border: 1px solid #e0e0e0;
 
 
147
  }
148
  @media (min-width: 768px) {
149
  .main-container {
 
54
  <p>πŸ“„ <strong>Document RAG:</strong> Answer based on uploaded medical documents</p>
55
  <p>🌐 <strong>Web Search:</strong> Fetch knowledge from reliable online medical resources</p>
56
  <p>🌍 <strong>Multi-language:</strong> Automatic translation for non-English queries</p>
57
+ <p>Tips: Customise configurations, system prompt to see the magic happens!</p>
58
+ <p>Note: Case GPU aborted or MedSwin not ready, please select another model!</p>
59
  </center>
60
  """
61
  CSS = """
 
144
  font-weight: 500;
145
  background-color: #f5f5f5;
146
  border: 1px solid #e0e0e0;
147
+ overflow-y: auto;
148
+ max-height: 120px;
149
  }
150
  @media (min-width: 768px) {
151
  .main-container {
ui.py CHANGED
@@ -194,6 +194,8 @@ def create_demo():
194
  label="Model Status",
195
  interactive=False,
196
  visible=True,
 
 
197
  elem_classes="model-status"
198
  )
199
 
@@ -342,14 +344,14 @@ def create_demo():
342
  logger.error(f"Error calling load_model_with_gpu: {e}")
343
  status_lines.append(f"⏳ MedSwin ({model_name}): loading...")
344
 
345
- # TTS model status
346
  if TTS_AVAILABLE:
347
  if config.global_tts_model is not None:
348
  status_lines.append("βœ… TTS (maya1): loaded and ready")
349
  else:
350
- status_lines.append("⚠️ TTS (maya1): not loaded")
351
- else:
352
- status_lines.append("❌ TTS: library not available")
353
 
354
  # ASR (Whisper) model status
355
  if WHISPER_AVAILABLE:
@@ -382,14 +384,12 @@ def create_demo():
382
  else:
383
  status_lines.append(f"⚠️ MedSwin ({model_name}): not loaded")
384
 
385
- # TTS model status
386
  if TTS_AVAILABLE:
387
  if config.global_tts_model is not None:
388
  status_lines.append("βœ… TTS (maya1): loaded and ready")
389
- else:
390
- status_lines.append("⚠️ TTS (maya1): not loaded")
391
- else:
392
- status_lines.append("❌ TTS: library not available")
393
 
394
  # ASR (Whisper) model status
395
  if WHISPER_AVAILABLE:
@@ -441,7 +441,7 @@ def create_demo():
441
  torch.cuda.empty_cache()
442
  logger.debug("[STARTUP] Cleared GPU cache after medical model")
443
 
444
- # Step 2: Load TTS model (maya1)
445
  if TTS_AVAILABLE:
446
  logger.info("[STARTUP] Step 2/3: Loading TTS model (maya1)...")
447
  try:
@@ -449,15 +449,10 @@ def create_demo():
449
  if config.global_tts_model is not None:
450
  status_messages.append("βœ… TTS (maya1): loaded")
451
  logger.info("[STARTUP] βœ… TTS model loaded successfully!")
452
- else:
453
- status_messages.append("⚠️ TTS (maya1): failed")
454
- logger.warning("[STARTUP] ⚠️ TTS model failed to load")
455
  except Exception as e:
456
- status_messages.append("❌ TTS (maya1): error")
457
- logger.error(f"[STARTUP] TTS model loading error: {e}")
458
- else:
459
- status_messages.append("❌ TTS: library not available")
460
- logger.warning("[STARTUP] TTS library not installed")
461
 
462
  # Small delay to let GPU settle and clear cache
463
  time.sleep(2)
 
194
  label="Model Status",
195
  interactive=False,
196
  visible=True,
197
+ lines=3,
198
+ max_lines=3,
199
  elem_classes="model-status"
200
  )
201
 
 
344
  logger.error(f"Error calling load_model_with_gpu: {e}")
345
  status_lines.append(f"⏳ MedSwin ({model_name}): loading...")
346
 
347
+ # TTS model status (only show if available or if there's an issue)
348
  if TTS_AVAILABLE:
349
  if config.global_tts_model is not None:
350
  status_lines.append("βœ… TTS (maya1): loaded and ready")
351
  else:
352
+ # TTS available but not loaded - optional feature
353
+ pass # Don't show if not loaded, it's optional
354
+ # Don't show TTS status if library not available (it's optional)
355
 
356
  # ASR (Whisper) model status
357
  if WHISPER_AVAILABLE:
 
384
  else:
385
  status_lines.append(f"⚠️ MedSwin ({model_name}): not loaded")
386
 
387
+ # TTS model status (only show if available and loaded)
388
  if TTS_AVAILABLE:
389
  if config.global_tts_model is not None:
390
  status_lines.append("βœ… TTS (maya1): loaded and ready")
391
+ # Don't show if TTS library available but model not loaded (optional feature)
392
+ # Don't show TTS status if library not available (it's optional)
 
 
393
 
394
  # ASR (Whisper) model status
395
  if WHISPER_AVAILABLE:
 
441
  torch.cuda.empty_cache()
442
  logger.debug("[STARTUP] Cleared GPU cache after medical model")
443
 
444
+ # Step 2: Load TTS model (maya1) - optional, only show if loaded
445
  if TTS_AVAILABLE:
446
  logger.info("[STARTUP] Step 2/3: Loading TTS model (maya1)...")
447
  try:
 
449
  if config.global_tts_model is not None:
450
  status_messages.append("βœ… TTS (maya1): loaded")
451
  logger.info("[STARTUP] βœ… TTS model loaded successfully!")
452
+ # Don't show status if TTS failed to load (it's optional)
 
 
453
  except Exception as e:
454
+ logger.warning(f"[STARTUP] TTS model loading error (optional): {e}")
455
+ # Don't show TTS status if library not available (it's optional)
 
 
 
456
 
457
  # Small delay to let GPU settle and clear cache
458
  time.sleep(2)