MOSS-Image / README.md
Phospheneser's picture
docs: update resource links and add Discord community link
2181622
|
Raw History Blame Contribute Delete
6.58 kB
metadata
title: MOSS Image
emoji: 🖼
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: 6.30.0
python_version: '3.12'
app_file: app.py
pinned: false
license: apache-2.0
short_description: Official demo of MOSS-Image.

MOSS-Image Demo

Hugging Face · MOSS-Image-Base   Hugging Face · MOSS-Image-SFT   ModelScope · MOSS-Image-Base   ModelScope · MOSS-Image-SFT   GitHub   Homepage   Technical Report   Follow OpenMOSS on X   MOSS-Image QQ 交流群:755535143   MOSS-Builders Feishu Community   MOSS-Image Discord Community

Gradio interface for MOSS-Image, including resolution and aspect-ratio presets, sampling controls, a selectable example gallery, advanced guidance controls, and live example/default-prompt updates.

Model loading

The Space preloads MOSS-Image-Base and MOSS-Image-SFT with snapshot_download(repo_id, revision=resolved_commit), followed by MOSSImagePipeline.from_pretrained(snapshot_path, local_files_only=True, ...). The Space explicitly loads its bundled pipeline, transformer and scheduler classes from pipeline_moss_image.py for the ZeroGPU AOT lifecycle. The bundled inference implementation follows the current Base pipeline, including negative-branch skipping and standard SLG. Progress is reported using the same bridge as the standalone app. Weights are downloaded into the Hugging Face cache; no local model directory or model weights in this repository are required.

Select MOSS-Image-Base or MOSS-Image-SFT in the Model dropdown before clicking Generate. Base is selected by default. The optional MOSS_MODEL_ID Space variable changes this initial selection.

Both transformers are loaded at startup. The text encoder, tokenizer and VAE are each shared only when their Hub file hashes match at the resolved revisions. Components that differ, such as model-specific VAEs, are loaded separately. Each model retains its own scheduler, prompt cache and revision metadata. Generation requests run serially; changing the dropdown does not change an already submitted request.

While the model repositories are private, configure an HF_TOKEN Space secret with read access to both models. Do not put a token in source files or ordinary Space variables. Local development uses the same environment variable or your cached Hugging Face login.

ZeroGPU

Both pipelines are loaded and placed on CUDA before the UI starts. Generation runs under @spaces.GPU(duration=80). At startup, a separate GPU allocation exports and AOT-compiles the repeated DiT and text-projection blocks with dynamic sequence lengths. Both models reuse the compiled graphs with their own weights. Compilation is validated against eager block outputs before the UI starts. This uses ZeroGPU AOTInductor support, not runtime torch.compile; GPU residency is fixed. Set the Space variable MOSS_AOTI=0 to run the eager baseline. Compilation happens once per container start and is not part of image generation latency. The 80-second budget is scaled to 120 seconds by the current RTX PRO 6000 ZeroGPU SDK configuration; it is not a measured latency guarantee. Large images or batches may require more time or memory than the allocation allows.

Outputs and version-2 parameter JSON files are stored under outputs/gradio/. Records include the model repository and resolved revision, actual seed, sampling parameters, component configuration hashes, execution backend, and software versions. Space storage is ephemeral; save generated images you want to keep.

Local development

pip install -r requirements.txt
python app.py

To inspect the UI without downloading weights or allocating a GPU:

python app.py --preview --port 7861

The UI and size presets follow the MOSS-Image development repository (main at 8a3223c). CFG defaults to 3; advanced settings contain CFG, shift and the Off / Negative-branch skipping / Standard SLG modes. Aspect ratios span 1:8–8:1. Examples restore their prompts, sampling settings and seed; unknown seeds become random (-1). Example files and default prompts refresh every two seconds.

ZeroGPU keeps the two official model choices, startup preloading, matching-component sharing and AOT compilation. Memory mode and runtime Compile DiT controls are not shown because GPU residency and compilation are managed at startup. The generation API returns the gallery and status, matching the standalone interface.

Licenses

Model weights use Apache-2.0. Bundled pipeline code retains its BSD 3-Clause license in LICENSE-CODE. See NOTICE.md for component attribution and the licenses in third_party/.