dung-vpt-uney commited on
Commit
454a159
·
1 Parent(s): f1e4aa7

Deploy latest CoRGI Gradio demo

Browse files
PROGRESS_LOG.md CHANGED
@@ -13,6 +13,7 @@
13
  - Added ZeroGPU support: cached model/processor globals live on CUDA when available, a `@spaces.GPU`-decorated executor handles pipeline runs, and requirements now include the `spaces` SDK.
14
  - Introduced structured logging for the app (`app.py`) and pipeline execution to trace model loads, cache hits, and Gradio lifecycle events on Spaces.
15
  - Reworked the Gradio UI to show per-step panels with annotated evidence galleries, giving each CoRGI reasoning step its own window alongside the final synthesized answer.
 
16
 
17
  ## 2024-10-21
18
  - Updated default checkpoints to `Qwen/Qwen3-VL-8B-Thinking` and verified CLI/Gradio/test coverage.
 
13
  - Added ZeroGPU support: cached model/processor globals live on CUDA when available, a `@spaces.GPU`-decorated executor handles pipeline runs, and requirements now include the `spaces` SDK.
14
  - Introduced structured logging for the app (`app.py`) and pipeline execution to trace model loads, cache hits, and Gradio lifecycle events on Spaces.
15
  - Reworked the Gradio UI to show per-step panels with annotated evidence galleries, giving each CoRGI reasoning step its own window alongside the final synthesized answer.
16
+ - Preloaded the default Qwen3-VL model/tokenizer at import so Spaces load the GPU weights before serving requests.
17
 
18
  ## 2024-10-21
19
  - Updated default checkpoints to `Qwen/Qwen3-VL-8B-Thinking` and verified CLI/Gradio/test coverage.
corgi/__pycache__/cli.cpython-313.pyc CHANGED
Binary files a/corgi/__pycache__/cli.cpython-313.pyc and b/corgi/__pycache__/cli.cpython-313.pyc differ
 
corgi/__pycache__/gradio_app.cpython-313.pyc CHANGED
Binary files a/corgi/__pycache__/gradio_app.cpython-313.pyc and b/corgi/__pycache__/gradio_app.cpython-313.pyc differ
 
corgi/gradio_app.py CHANGED
@@ -50,6 +50,20 @@ def _default_factory(model_id: Optional[str]) -> CoRGIPipeline:
50
  return CoRGIPipeline(vlm_client=Qwen3VLClient(config=config))
51
 
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  def _get_pipeline(model_id: str, factory: Callable[[Optional[str]], CoRGIPipeline]) -> CoRGIPipeline:
54
  pipeline = _PIPELINE_CACHE.get(model_id)
55
  if pipeline is None:
@@ -387,6 +401,11 @@ def build_demo(
387
  global _GLOBAL_FACTORY
388
  _GLOBAL_FACTORY = factory
389
  logger.info("Registering pipeline factory %s", factory)
 
 
 
 
 
390
 
391
  with gr.Blocks(title="CoRGI Qwen3-VL Demo") as demo:
392
  state = gr.State() # stores PipelineState
 
50
  return CoRGIPipeline(vlm_client=Qwen3VLClient(config=config))
51
 
52
 
53
+ def _warm_default_pipeline() -> None:
54
+ if DEFAULT_MODEL_ID in _PIPELINE_CACHE:
55
+ return
56
+ try:
57
+ logger.info("Preloading default pipeline for model_id=%s", DEFAULT_MODEL_ID)
58
+ _PIPELINE_CACHE[DEFAULT_MODEL_ID] = _default_factory(DEFAULT_MODEL_ID)
59
+ except Exception as exc: # pragma: no cover - defensive
60
+ logger.exception("Failed to preload default model %s: %s", DEFAULT_MODEL_ID, exc)
61
+
62
+
63
+ _GLOBAL_FACTORY = _default_factory # type: ignore[assignment]
64
+ _warm_default_pipeline()
65
+
66
+
67
  def _get_pipeline(model_id: str, factory: Callable[[Optional[str]], CoRGIPipeline]) -> CoRGIPipeline:
68
  pipeline = _PIPELINE_CACHE.get(model_id)
69
  if pipeline is None:
 
401
  global _GLOBAL_FACTORY
402
  _GLOBAL_FACTORY = factory
403
  logger.info("Registering pipeline factory %s", factory)
404
+ try:
405
+ logger.info("Preloading pipeline with factory for model_id=%s", DEFAULT_MODEL_ID)
406
+ _PIPELINE_CACHE[DEFAULT_MODEL_ID] = factory(DEFAULT_MODEL_ID)
407
+ except Exception as exc: # pragma: no cover - defensive
408
+ logger.exception("Unable to preload pipeline via factory: %s", exc)
409
 
410
  with gr.Blocks(title="CoRGI Qwen3-VL Demo") as demo:
411
  state = gr.State() # stores PipelineState