Wan-2.2-Studio / README.md
amisima's picture
Restore the previous WAN sources
3aa4b09 verified
|
Raw History Blame Contribute Delete
20.4 kB
---
title: Wan 2.2 Studio · AI Scene Planner
emoji: 🎬
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: 6.24.0
app_file: app.py
hf_oauth: true
pinned: true
short_description: 'NEW: LoRA size guard, CPU downloads & AI scene planning'
tags:
- video
- image-to-video
- wan
- wan2.2
- lora
- zerogpu
- scene-planning
- video-to-audio
---
# 🎬 Wan 2.2 Studio
**One image. One idea. A scene built in stages.**
Upload an image, describe what should happen, choose the video length and press **Generate**.
The complete set of controls is available in the collapsed **More settings** section.
The same controls, saved profiles, LoRAs, Identity Lock, audio and Extend tools remain available.
**Optional image assistant:** Qwen3.8 remains selected by default. More settings also offers
the dedicated CPU caption assistant when you have access to its Space. It makes one image
description request, capped at 384 tokens with temperature 0, and preserves your original
instructions, LoRA selection and strengths. With text alone it keeps the description without
an AI request. It does not translate or plan scenes, choose LoRAs, tune strengths or write
sound descriptions; those AI tasks require Qwen3.8. There is no automatic retry or fallback.
**🆕 AI Scene Planner · 🔒 Improved Identity Lock · 🔊 3 audio models · 🎞️ Up to 64 clips**
## 🆕 LoRA preparation before GPU — size checks and complete downloads
All selected LoRA files, including built-in presets, Hugging Face files and CivitAI/direct
links, are downloaded and checked **before the video GPU request**. Progress shows preparation
and downloaded MiB for direct links. Valid cached downloads are reused across clips and runs
while the files remain on the Space's disk.
- **1024 MiB (1 GiB) per file** and **3072 MiB (3 GiB) across enabled adapter files** by default.
High and Low files both count; optional speed adapters count too. A zero-strength half is skipped.
- Prompt and Split into clips suggestions exclude adapters known to exceed the limits. General
all-in-one options stay pinned when they fit; General NSFW Booster's current High/Low pair fits.
- Manual Pro selections are checked too. Oversized or incomplete files stop preparation with a
clear error **before reserving the video GPU**. A size rejection does not blacklist the adapter.
- Missing size metadata is not treated as a small file: direct downloads enforce the byte limit
while streaming. New URL downloads become reusable only after size and safetensors extent checks.
Partial files from interrupted downloads are not accepted as ready weights.
Loading the prepared weights into the video model still takes GPU time. The reservation now adds
a size-based allowance: **2 seconds per enabled file plus 10 seconds per GiB**, with a larger margin
in Safe Mode. This is an estimate, not a benchmark or a guarantee against timeouts. Without optional
LoRAs there is no new loading allowance. File size is only a practical guard; it cannot prove model
compatibility or predict every adapter's memory use. These changes were tested locally without
running GPU inference.
## 🆕 Smaller GPU requests and steadier rendering
Normal mode restores the earlier, lighter GPU reservation policy. It removes the unconditional
60-second minimum, the added 35% denoising margin and the fixed 35/120-second adapter-loading surcharge.
Selected adapters now use the size-based loading allowance described above.
**Safe Mode** keeps conservative reserves for adapter loading and slow runs; it is off by default.
Existing saved profiles and ready-made setups can still enable it.
Suitable images keep their native size: a 512×768 upload stays 512×768 instead of being enlarged
to 560×832. Dimensions still follow the checkpoint's 16-pixel grid and configured size bounds.
The estimate now uses the same image-sizing policy and both guidance settings as generation.
For a 512×768 input, 9 seconds, 32 FPS, 8 steps, guidance 1/1, no optional LoRAs and Safe Mode off, the code computes
about **206 seconds of requested xlarge allowance**. At 3.5 seconds and 6 steps it computes about
**54 seconds**. These are reservation calculations, not measured runtimes or a promise that a
particular request will fit the quota remaining on your account. Adding LoRAs increases the loading
allowance. Audio and AI planning have their own additional processing.
RIFE frames are encoded as they become ready instead of keeping a second complete interpolated
video in RAM. Joining normalises one clip at a time, then combines the prepared files without
another video encode. Video, audio, local enhancement and joining share one heavy-work queue.
## 🆕 LoRA Refresh — relevant choices, continuous browsing
**Prepare prompt & LoRA/effects** and **Split into clips** share one selection.
Refresh browses up to **five relevant rotating suggestions**, wraps back to the beginning and
keeps up to **two selected adapters** ticked. If both places are occupied, ticking another suggestion
replaces the oldest selection; the new choice is no longer silently ignored. It uses local name/trigger matching and link checks;
**Refresh does not call an AI model or request a GPU**. Suggestions are not random.
General NSFW **all-in-one / AIO** entries, including **General NSFW Booster**, stay visible on every
page as extra options when they fit the size limits. They are not enabled automatically, and do not
displace the five rotating suggestions. Confirmed invalid or oversized entries remain excluded,
including all-in-one entries.
- Unavailable links, oversized files and explicitly incompatible base-model metadata are filtered
from rotating suggestions. Confirmed bad entries are remembered for 24 hours, then checked again
so repaired files can return. Unknown file sizes are checked during preparation.
- Authentication errors, rate limits and timeouts do not permanently blacklist an adapter.
All-in-one choices remain visible through temporary availability failures.
- Link checks cannot prove that weights load correctly or that an effect will look good.
- **Automatic trigger sync:** selecting, replacing or clearing an adapter updates the main prompt
and every non-empty clip prompt. All selected adapters are loaded for each clip, so their known
activation words are applied consistently; prompt-word matching no longer suppresses them.
- The app removes only insertions it has tracked in the current session. It preserves your original
words, handles reordered clip lines and keeps text appended after an inserted trigger. Words
imported from an older profile without insertion history are treated as user-authored text.
- Explicit trigger metadata can come from saved catalogue entries, built-in adapter metadata or
CivitAI's trained words. Missing metadata is reported; the app does not invent activation words.
- Manual changes through LoRA Studio, the built-in/custom controls and the quick-link control
also sync known activation words. This uses no writing model or GPU request.
- Initial preparation can ask the writing model to choose suitable adapters; it can choose none.
Refresh preserves your choices and does not rewrite prompts with AI or regenerate the scene.
The existing catalogue and manual controls in **Pro** remain available. Each panel gets its own
Gradio update object to prevent stale selections falling outside the displayed choices. Manual
catalogue lists are not pruned; their selected files still pass the same limits before generation.
## 🆕 AI Scene Planner — available in Simple
Describe the entire sequence once. The selected writing model suggests **how many clips it needs,
how long each clip should be, and a separate prompt for every stage**.
1. Upload the starting image and write the complete sequence in **The whole scene**.
2. Press **🪄 Split into clips**. Automatic clip count and automatic timing are on by default.
3. Press **🎬 Make the whole scene and join it** to generate the clips in order and join them.
No manual prompt splitting is required. You can open **Review or edit the clip prompts** if you
want to adjust a prompt or its timing. A blank scene idea uses the main prompt. Ideas can be
written in Bulgarian or English; the generated clip prompts are in English for Wan.
For example: **“The character turns around, crouches, then claps while crouching.”**
| Stage | Main action | Example proposed time | Continuity |
| --- | --- | --- | --- |
| Clip 1 | Turn around and settle | About 3 s | Finish facing the new direction |
| Clip 2 | Lower into a crouch | About 2.5 s | Begin from the previous ending pose |
| Clip 3 | Clap while remaining crouched | About 1.5 s | Keep the crouch and camera position |
These times are illustrative. The model estimates them from your idea, and the app aligns them
to Wan's supported frame grid. The model is asked to keep one main action or a natural movement
phase in each clip, preserve the action order and describe a usable ending pose. Actual video
motion and exact action completion still depend on the video model.
The plan shows each prompt, its duration and the approximate total running time. Longer plans
are written in small batches while retaining the preceding stages as context. If a response is
incomplete or invalid, your existing plan is kept. Planning does not start video generation.
**Why 64 instead of 8?** Eight was an application limit, not a limit of the Wan model. This build
supports **1–64 clips per scene run**, with one generation request per clip. Available ZeroGPU time
still determines how much can finish. Clips accumulate in the queue and are joined once at the end; **Start at clip**
lets you resume a stopped run while the session's images and generated clips are still available.
The planner uses the **Big model Space** selected in **Pro → Prompt Assist**, initially
`amisima/Qwen3.8-27B-Uncensored-Demo`. It sends that Space the idea and reference image and uses
a separate request to that Space. Public writer calls are anonymous by default. A private or
restricted writer may require the owner to configure `EXPANDER_HF_TOKEN`; see the notes below.
## ✨ Simple — guided creation
- **Prepare prompt & effects:** expand the idea using the photo, suggest matching effects and set
their strengths and trigger words. Suggested choices remain editable.
- **AI Scene Planner:** automatically split a longer idea into clip prompts and individual timings.
- **Identity Lock:** optionally supply a separate portrait to help limit face drift.
- **Scene Builder:** generate a chain, join its clips, or add just one more clip.
- **Audio Studio:** select any of the three sound models directly in Simple.
## 🔒 Improved Identity Lock
Use a clear portrait at a similar face angle. Before each clip, the app checks the starting frame
and can gently correct it toward the reference. Eyes and mouth are protected to preserve
expression. Face similarity is checked locally when available, with alignment checks as a fallback.
Correction is reduced for an already close match or difficult alignment, and limited more gently
for continuations. Set the strength to zero or leave the portrait empty to disable it.
**This corrects the starting frame; it does not guarantee an identical face throughout every
frame of the generated video.**
## 🔊 Audio Studio — three model choices
| Model | Purpose |
| --- | --- |
| **MMAudio NSFW — new default** | Specialized 44 kHz checkpoint |
| **MMAudio** | Standard, lighter sound generation option |
| **HunyuanVideo-Foley** | Alternative Foley model with heavier processing |
Wan generates the video first; audio is a separate pass. Add sound to an existing clip or enable
**Sound on every clip**. During an automatic scene chain, the app adds sound to the joined scene
at the end. Audio uses additional GPU time, and the selected model downloads on first use.
Selecting the default model does not enable automatic sound by itself.
Pro adds sound steps, guidance and a negative prompt. An empty negative prompt applies no
exclusions. The selected audio model and its settings are included in saved profiles.
## 🎛️ Pro — all tools & settings
| Tool | What you can do |
| --- | --- |
| **LoRA Studio** | Mix up to 3 built-in effects and use 5 custom High/Low slots |
| **CivitAI search & shared library** | Search adapters, paste model links, inspect names and tune strengths |
| **Prompt Assist** | Set camera, framing, lighting and pacing; use a local enhancer or the selected writing Space |
| **Frame Control** | Supply an optional end image or reuse a frame from the generated video |
| **Speed Studio** | Choose speed presets and tune steps, scheduler and flow shift |
| **RIFE interpolation** | Add frames for smoother playback after generation |
| **Loop Studio** | Make a full boomerang or loop the ending on the CPU |
| **Final Cut** | Join clips into one downloadable video on the CPU |
| **JSON Profiles** | Save named setups or import and export scene plans and generation settings |
The GPU estimate takes the scene's individual clip durations into account. It estimates requested
allowance, not a guaranteed completion time. Joining and looping do not consume extra ZeroGPU time.
RIFE adds interpolated frames; it does not generate new actions.
## 💾 Save your scene plan
JSON profiles include the scene idea, clip count, per-clip prompts, per-clip seconds, automatic
planning preferences and audio settings. Older profiles still load and start with an empty scene
plan, so a previous plan is not accidentally reused. Uploads and generated clips are not embedded
in settings JSON; loading a profile resets **Start at clip** to 1.
Named profiles inside this Space are shared with its visitors. Download a settings JSON if you
want to keep a setup without adding it to the shared list.
## Please read before uploading a photograph
Upload only photographs of yourself, or of people who have agreed to this. **Sexual imagery of a real
person, made without that person's consent, breaks Hugging Face's
[content policy](https://huggingface.co/content-policy) and is not welcome here.** The same applies to
anything involving a minor, in any form, without exception.
This Space is tagged *Not For All Audiences*: adapters loaded into it may produce adult material, and
what a visitor loads is their own responsibility under that policy.
## Setup notes for the Space owner
- `EXPANDER_SPACE` sets the initial writing Space. Visitors can select another **Big model Space**
in Pro → Prompt Assist.
- `HF_TOKEN` remains for model downloads and the existing catalogue/storage operations. It is no
longer automatically passed to the external writing Space. This prevents visitors' AI calls
silently inheriting the owner's download token.
- `EXPANDER_HF_TOKEN` is an **optional explicit opt-in** for authenticated writing requests. Those
requests can use that token owner's quota/credits. Leave it unset for anonymous public writers;
restricted/private writers can require it. This change can affect access to your existing writer.
- A failed or timed-out writing request is not automatically replayed against other endpoints.
Timeout cancellation is best effort; a job already running remotely can still consume resources.
Large scene plans can intentionally use several batches, and initial prompt preparation can
separately request adapter selection. Repeated user clicks also start new requests.
- Set `CIVITAI_TOKEN` in Settings → Variables and secrets for downloads that need authentication.
Signing in to CivitAI in your own browser does not authenticate the Space's server.
- `WAN_LORA_MAX_FILE_MB` (default `1024`) and `WAN_LORA_MAX_RUN_MB` (default `3072`) configure
the per-file and combined limits in **MiB**. Raising them allows heavier adapters and can bring
back memory pressure or timeouts. `WAN_LORA_DOWNLOAD_SECONDS` (default `600`) bounds streamed
direct downloads on the CPU; it does not increase the video GPU reservation. Hugging Face's
native downloader retains its own timeout/retry behavior.
- A custom adapter can use a Hugging Face repo, an individual file or a CivitAI link. High and Low
strengths are independently adjustable. Shared library entries include names and trigger words.
- Built-in presets are read from the private repo named by `LORA_CATALOG_REPO`. With it unset, the
Space can start without bundled presets and use custom slots.
* fp8 quantized, AoT compiled, with RIFE interpolation for smoother motion.
* An adapter carrying bias tensors cannot be loaded into a torchao-quantized layer, so the bias is
dropped and the rest of the adapter is loaded rather than the whole thing failing.
* Profiles live inside the Space, and are visible to everyone who opens it.
* The lora library lives in a storage bucket. Attach it to the Space under *Settings → Storage
Buckets* and nothing else is needed; name it with `LORA_LIBRARY_BUCKET` if it is not
`amisima/wan-2.2-lora-storage`, or point `LORA_LIBRARY_DIR` at the mount path directly. Without a
mounted bucket it falls back to an `HF_TOKEN` with write access.
## Execution and recovery
The scene runner requests one clip at a time and schedules the next only while work remains.
There is no fixed chain of 64 empty callbacks after a short scene. The scene button becomes
available again on completion, Stop or a handled error. Finished clips remain in the queue.
Use **🔗 Join queued clips / retry** to retry stitching without generating or adding a clip again.
Stitching subprocesses have time limits; an incomplete merge is not presented as success.
Stop cancels queued work and prevents the next scene step. An already-running synchronous GPU
operation may take time to return before its resources can be released.
The app uses the platform-installed `spaces` package instead of upgrading it during each boot.
Gradio SSR is disabled. An expired image now gives a specific re-upload message rather than an
unhandled missing-file traceback; the app cannot recover an upload deleted by a container restart.
Use **Runtime diagnostics** to download a bounded report with the boot ID, RAM figures, processing
stages and cgroup memory/OOM counters when available. Reports contain no prompts or photo contents.
LoRA diagnostics also record prepared MiB and GPU adapter-loading wall time, helping distinguish
a slow download from slow loading or denoising.
The report is stored under writable `/data` or `/bucket` with file-lock support, otherwise the
system temporary directory. History survives replacement only if the backing storage is persistent.
The supplied startup/error log did not establish an OOM crash or repeated restart. These changes
reduce concrete memory risks; the real restart cause still requires a live runtime report.
The app still relies on the Space's existing model files, helper modules and dependencies.
Replace `app.py` and this `README.md` in the corresponding Space; this update is not a complete
standalone repository. Local checks cover reservation and resize calculations, looping LoRA selection,
Gradio choices, trigger replacement in both prompt fields, manual slot changes, remote
authentication/retry limits, failure cleanup and real ffmpeg audio/video joins. Twenty-eight offline regression
tests passed, and the added event bindings were checked with Gradio 6.24.0. GPU model inference and the live browser
workflow must be verified in the Space.
## Quota and credit accounting
[ZeroGPU documentation](https://huggingface.co/docs/hub/en/spaces-zerogpu) distinguishes the requested
runtime limit from actual usage. xlarge has a 2× usage multiplier; eligible plans can consume prepaid
credits after included quota is exhausted. A larger reservation is not itself a billing receipt.
The [Inference Providers model breakdown](https://huggingface.co/docs/inference-providers/en/pricing)
is a different usage view. A screenshot showing $0.09 for ERNIE and $0.07 for DeepSeek accounts for
$0.16 of displayed provider charges. This Wan file does not directly call either model. A remote
writing Space's internals and the account's complete usage/billing history were not available,
so the originating application and any other credit consumption cannot be determined from that
screenshot. Included compute credits can be shared across eligible Hugging Face services.