Skip to content

Instruct gradio UI - #74

Open
auroter wants to merge 8 commits into
Tencent-Hunyuan:mainfrom
auroter:instruct-gradio-ui
Open

Instruct gradio UI#74
auroter wants to merge 8 commits into
Tencent-Hunyuan:mainfrom
auroter:instruct-gradio-ui

Conversation

@auroter

@auroter auroter commented Feb 1, 2026

Copy link
Copy Markdown

Fixed this so that I could use HunyuanImage-3.0-Instruct locally with the Gradio UI.

auroter and others added 8 commits January 31, 2026 07:31
Throttle yield frequency during token streaming (50ms debounce) to prevent
Gradio serialization of the full chatbot history from bottlenecking the
consumer. Also pre-filter messages in single_round mode to skip loading
images from old rounds that the pipeline discards anyway.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two changes to run_chatbot.py:

1. Throttle yield frequency (50ms debounce) during token streaming.
   Gradio serializes the full chatbot history on every yield. As images
   accumulate in history, each serialization gets more expensive. Reducing
   yields from ~200 to ~20-40 per generation keeps the consumer in sync
   with the producer.

2. Save generated images to /tmp files before storing in history.
   Gradio re-encodes PIL Image objects to PNG on every yield (even for
   unchanged old messages). Using file paths instead avoids the costly
   re-encoding, reducing per-yield overhead from ~60ms/image to near zero.

Also pre-filters messages in single_round mode to skip loading images
from old rounds that the pipeline discards anyway.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Close the file descriptor from mkstemp() to prevent fd exhaustion
  after many generations (EMFILE after ~1000 images)
- Use gr.Image(filepath) for user-uploaded images too, not just
  generated ones — same re-encoding problem on every yield
- Remove print(tmp_path) when no cache dir is set (undocumented
  behavioral change from original)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… and UI enhancements

Server (hunyuan_server.py):
- HTTP API server with /generate, /understand, /health endpoints
- Serialized generation via threading lock
- Seed reproducibility with RNG state save/restore

Pipeline & solvers (hunyuan_image_3_pipeline.py):
- Multi-solver support: euler, heun-2, midpoint-2, kutta-4
- Meanflow support for distilled models
- ClassifierFreeGuidance operator for non-distilled CFG

Gradio UI (run_chatbot.py):
- Flow shift slider, solver dropdown
- Visual intelligence mode (TI2T) and likeness system prompt presets
- Config logging at startup

System prompts (system_prompt.py):
- Likeness synthesis prompt for identity-preserving generation
- Visual intelligence (TI2T) prompt

Reproducibility (pipeline.py):
- Seed all RNGs before generation, restore state after
- Config info printed at load time

Cleanup:
- Remove dead code files superseded by upstream refactor
  (configuration_hunyuan.py, hunyuan.py, tokenizer_wrapper.py)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The model's generate() reads diffusion params from generation_config
(loaded from weights/generation_config.json), not from kwargs. Our
server was passing them as kwargs, so they were always the model
defaults (guidance=2.5, steps=8/50).

Fix: set model.generation_config directly before each call, restore
after. Safe because gen_lock serializes all generation.

This means all previous experiments that varied guidance via the API
were actually running at guidance=2.5 the entire time.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant