$npx -y skills add huggingface/skills --skill huggingface-lora-space-builderBuild and publish a Gradio demo on Hugging Face Spaces for a user-provided LoRA. Use when someone asks to create, generate, ship, or publish a Space, demo, Gradio app, or playground for a LoRA — including LoRAs for Qwen-Image, Qwen-Image-Edit, LTX-Video, Wan, FLUX, SDXL, or other
| 1 | # Gradio LoRA Space Builder |
| 2 | |
| 3 | Build and publish a Gradio demo on Hugging Face Spaces that runs inference with a user-provided LoRA. Use whenever someone asks to create, generate, ship, or publish "a Space", "a demo", "a Gradio app", or "a playground" for a LoRA — whether the base model is Qwen-Image, Qwen-Image-Edit, LTX, or another diffusion model. Also use when someone describes a LoRA they trained or hosts on the Hub and wants to share it. The default target is ZeroGPU hardware and the default inference library is `diffusers` when the base model supports it. |
| 4 | |
| 5 | The output is a real, published Space (private by default) that the user can try in the browser, not a local script. |
| 6 | |
| 7 | ## What "good" looks like for these demos |
| 8 | |
| 9 | The demo should feel handcrafted for this specific LoRA, not a generic template with the LoRA bolted on. Two LoRAs that share a task can still need different demos: a pose-control video LoRA and an outpainting video LoRA both take video in and produce video out, but the inputs the user provides, the preprocessing, and the controls are completely different. Recognizing that is the central job here. |
| 10 | |
| 11 | Concretely, a good demo: |
| 12 | |
| 13 | - Loads fast and runs fast — minimal model loading, sensible step count, no wasted computation per call. |
| 14 | - Has a UI with exactly the controls this LoRA needs and nothing else. Excess sliders are a cost, not a feature. |
| 15 | - Shows the user what's happening — progress, intermediate outputs where useful, the seed used, a clear error when input is missing. |
| 16 | - Honors the LoRA's own recommendations from its model card: trigger words, recommended step count, recommended guidance scale, recommended LoRA scale, example inputs. |
| 17 | - Is creative where creativity helps — interactive canvases, before/after sliders, side-by-side previews of intermediate processing — and plain where plainness is right. |
| 18 | |
| 19 | ## Workflow |
| 20 | |
| 21 | Work through these phases in order. Information gathered in one phase decides the next. |
| 22 | |
| 23 | 1. Gather the LoRA info needed to pick a pipeline and design a UI. |
| 24 | 2. Pick the base pipeline and inference recipe. |
| 25 | 3. Design the UI for this specific LoRA's task and inputs. |
| 26 | 4. Write `app.py`, `requirements.txt`, and `README.md` together; show all three to the user for one batched approval. |
| 27 | 5. Publish the Space (private). |
| 28 | |
| 29 | Don't drip-feed questions across multiple turns. Batch them. |
| 30 | |
| 31 | --- |
| 32 | |
| 33 | ## Phase 1 — Gather LoRA info |
| 34 | |
| 35 | Required: a LoRA repo on the Hub (e.g. `username/my-lora`). |
| 36 | |
| 37 | **First, try to read the repo without a token.** If it succeeds, the repo is public — proceed. If it fails with 401/403, the repo is private/gated and you need an authenticated session to read it. **Don't immediately ask for a token.** Check first whether the user is already authenticated. |
| 38 | |
| 39 | ```python |
| 40 | from huggingface_hub import HfApi, get_token |
| 41 | |
| 42 | cached_token = get_token() # picks up HF_TOKEN env var or cached CLI login |
| 43 | if cached_token: |
| 44 | try: |
| 45 | info = HfApi().whoami(token=cached_token) |
| 46 | username = info["name"] |
| 47 | # info also has fine-grained token scope info if applicable |
| 48 | except Exception: |
| 49 | cached_token = None # token exists but is invalid/expired |
| 50 | ``` |
| 51 | |
| 52 | Then: |
| 53 | |
| 54 | - If a valid cached token exists *and* it can read the repo, use it. No prompt needed. |
| 55 | - If no cached token, or the cached token can't read this private repo, ask the user for a token — once, with the explanation below. |
| 56 | |
| 57 | When asking for a token (and only when you actually need to ask): |
| 58 | |
| 59 | > I need a Hugging Face access token with **write** scope (to read the LoRA if it's private/gated, and to publish the Space). Create one at https://huggingface.co/settings/tokens. Paste it here. |
| 60 | |
| 61 | The same token will be reused for publishing in the final phase, so this is a one-time ask. |
| 62 | |
| 63 | **Then read what's in the repo:** |
| 64 | |
| 65 | - List the repo files (`huggingface_hub.HfApi().list_repo_files(repo_id)`). Look for `.safetensors`, `README.md`, example images/videos, multiple checkpoints. |
| 66 | - Fetch the model card (`huggingface_hub.ModelCard.load(repo_id)`). The `data` dict has structured fields; the `text` has the README body. |
| 67 | - If multiple `.safetensors` files exist, pick the right one — see "Picking the LoRA weights file" in `references/zerogpu-and-publishing.md`. Briefl |