Instruct gradio UI - #74
Open
auroter wants to merge 8 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed this so that I could use HunyuanImage-3.0-Instruct locally with the Gradio UI.