跳到正文
Skillpedia
机器学习11k · #11775

huggingface-lora-space-builder

它能做什么

这个技能为 LoRA 构建浏览器演示。LoRA 是一种用于定制图像或视频模型的小型附加组件。适合训练或托管了 LoRA、并希望分享可用演示的创作者。

适用场景

  • ✓当你想为 LoRA 模型发布 Space 或演示时。
  • ✓当你训练了 LoRA,并希望把它分享为交互式体验环境时。
  • ✓当你想为带有 LoRA 的扩散模型(如 FLUX、SDXL 或 Wan)制作演示的时候。

技能链接

https://github.com/huggingface/skills/blob/main/skills/huggingface-lora-space-builder/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/huggingface/skills/blob/main/skills/huggingface-lora-space-builder/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请发布一个 Space,让人们可以用我的 LoRA 在 FLUX 上生成产品照片,并提供一个简单的提示词输入框。”

每周 5 个新技能,1 分钟读完。

工作原理

AI 会只设计 LoRA 所需的控件,然后把它编写成 Gradio 应用并发布到 Hugging Face Spaces。Space 默认为私密,因此你可以决定何时分享。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Gradio LoRA Space Builder

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.

The output is a real, published Space (private by default) that the user can try in the browser, not a local script.

What "good" looks like for these demos

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.

Concretely, a good demo:

  • Loads fast and runs fast — minimal model loading, sensible step count, no wasted computation per call.
  • Has a UI with exactly the controls this LoRA needs and nothing else. Excess sliders are a cost, not a feature.
  • Shows the user what's happening — progress, intermediate outputs where useful, the seed used, a clear error when input is missing.
  • Honors the LoRA's own recommendations from its model card: trigger words, recommended step count, recommended guidance scale, recommended LoRA scale, example inputs.
  • Is creative where creativity helps — interactive canvases, before/after sliders, side-by-side previews of intermediate processing — and plain where plainness is right.

Workflow

Work through these phases in order. Information gathered in one phase decides the next.

  1. Gather the LoRA info needed to pick a pipeline and design a UI.
  2. Pick the base pipeline and inference recipe.
  3. Design the UI for this specific LoRA's task and inputs.
  4. Write app.py, requirements.txt, and README.md together; show all three to the user for one batched approval.
  5. Publish the Space (private).

Don't drip-feed questions across multiple turns. Batch them.


Phase 1 — Gather LoRA info

Required: a LoRA repo on the Hub (e.g. username/my-lora).

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.

from huggingface_hub import HfApi, get_token

cached_token = get_token()  # picks up HF_TOKEN env var or cached CLI login
if cached_token:
    try:
        info = HfApi().whoami(token=cached_token)
        username = info["name"]
        # info also has fine-grained token scope info if applicable
    except Exception:
        cached_token = None  # token exists but is invalid/expired

Then:

  • If a valid cached token exists and it can read the repo, use it. No prompt needed.
  • 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.

When asking for a token (and only when you actually need to ask):

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.

The same token will be reused for publishing in the final phase, so this is a one-time ask.

Then read what's in the repo:

  • List the repo files (huggingface_hub.HfApi().list_repo_files(repo_id)). Look for .safetensors, README.md, example images/videos, multiple checkpoints.
  • Fetch the model card (huggingface_hub.ModelCard.load(repo_id)). The data dict has structured fields; the text has the README body.
  • If multiple .safetensors files exist, pick the right one — see "Picking the LoRA weights file" in references/zerogpu-and-publishing.md. Briefly: README-recommended file wins, then pytorch_lora_weights.safetensors, then latest training checkpoint, otherwise ask.

From the model card, try to determine:

  • Base model — the base_model field, or text mentions in the README. Usually present. Use it to pick the pipeline reference file (see P
常见问题

这个 Space 是公开的吗?

默认是私密的,因此你可以在分享之前先进行审阅。

它使用什么硬件?

默认目标是 ZeroGPU 硬件,并且在基础模型支持时,该技能会使用 diffusers。

它只适用于图像模型吗?

不是。该技能也涵盖 LTX 和 Wan 等视频扩散模型。

详情

作者的原始描述

Build 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 diffusion base models. Also triggers when someone describes a LoRA they trained or hosts on the Hub and wants to share it. Covers picking the right base pipeline and `diffusers` inference recipe, designing a UI tailored to the LoRA's task and inputs (Union/multi-task control, edit, video, image, etc.), respecting mode

repo: huggingface/skills

热度

GitHub 星标
11k
排名
#11775
许可证
Apache-2.0
更新时间
2026/10/30

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能