AI Apps in a Flash with Gradio's Reload Mode
Gradio's reload mode, launched with `gradio app.py` instead of `python app.py`, hot-swaps source changes into a running server instead of restarting it as uvicorn's auto-reload does. Gradio built its own reloader for faster UI iteration and for selective reloading: code wrapped in `if gr.NO_RELOAD:` (such as model loading or client setup) runs only once. A worked example builds a document question-answering chat app on the Hugging Face Inference API, chaining a LayoutLM document-QA model with Zephyr-7B and a system prompt, built iteratively in about an hour.
Related posts
- Gradio-Lite: Serverless Gradio Running Entirely in Your Browser
Hugging Face mediumAdeptGradio-Lite (@gradio/lite) is a JavaScript library that runs Python Gradio apps entirely in the browser using Pyodide, the WebAssembly build of CPython, so no server is needed. Apps are written in Python inside a <gradio-lite> HTML tag. Multi-file apps use <gradio-file> tags with an entrypoint, and extra dependencies are installed via micropip from a <gradio-requirements> block, for example transformers_js_py for in-browser sentiment classification. The main costs are a 5–15 second initial load while Pyodide downloads and the fact that only Pyodide-compatible packages work.
- Any Custom Frontend with Gradio's Backend
Hugging Face mediumAdeptgradio.Server extends FastAPI so any custom frontend (React, Svelte or plain HTML/JS) can sit on top of Gradio's backend, which provides queuing, concurrency control, SSE streaming, gradio_client compatibility and ZeroGPU support on Hugging Face Spaces. A Text Behind Image editor shows the pattern: about 50 lines of Python expose a BiRefNet background-removal endpoint via @app.api() and serve a ~1300-line vanilla HTML/JS app via a normal FastAPI route. The frontend calls the endpoint through the Gradio JS client rather than raw fetch, so requests go through the queue and concurrent GPU calls don't collide.
- One-Shot Any Web App with Gradio's gr.HTML
Hugging Face mediumAdeptGradio 6's gr.HTML now accepts an html_template, scoped css_template and js_on_load script, so a fully custom interactive component (frontend, backend and state) fits in one Python file that an LLM can generate in one shot. Python state is injected with ${value}, updated from JavaScript through props.value, and synced back with trigger('change'). Subclassing gr.HTML turns such a component into a reusable one that works like gr.Image or gr.Slider. Examples include a Pomodoro timer, a Kanban board with native HTML5 drag-and-drop, a contribution heatmap, an ML detection viewer, a Three.js camera control and a live speech transcription display, all deployable to Hugging Face Spaces without a build step.
- Run ComfyUI workflows for free with Gradio on Hugging Face Spaces
Hugging Face mediumAdeptA ComfyUI node workflow can be turned into a standalone Gradio app and hosted for free on Hugging Face Spaces' serverless ZeroGPU tier. The steps: export the workflow to Python with ComfyUI-to-Python-Extension, then rewrite its main() into a generate_image function whose hard-coded node values become UI inputs and which returns the saved image path. To prepare for Spaces, fetch the models with hf_hub_download instead of uploading them, wrap inference in the @spaces.GPU decorator, and merge the custom nodes' dependencies into one requirements.txt. Loading models in global scope, outside the decorated function, keeps ZeroGPU from reloading them from disk on every run.
- Introducing Daggr: Chain apps programmatically, inspect visually
Hugging Face mediumAdeptDaggr is an open-source Python library from the Gradio team for chaining Gradio Spaces, Hugging Face Inference Providers models and custom Python functions into workflows defined in code, with an automatically generated visual canvas. The canvas lets you inspect intermediate outputs, change inputs and rerun individual steps, while state, cached results and multiple "sheets" persist between sessions. Three node types are covered: GradioNode, which can clone and run a Space locally with remote fallback; FnNode; and InferenceNode. A walkthrough builds an image-to-3D pipeline from background removal, downscaling, FLUX.2-klein and TRELLIS.2. The library is in beta, so APIs may change and data loss is possible during updates.