Spaces:
Running on Zero
Running on Zero
README for the Workflow version: parity table, design notes, hf_oauth scopes
Browse files
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title: MOSS
|
| 3 |
emoji: 🖼
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: indigo
|
|
@@ -7,113 +7,82 @@ sdk: gradio
|
|
| 7 |
sdk_version: 6.30.0
|
| 8 |
python_version: "3.12"
|
| 9 |
app_file: app.py
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
pinned: false
|
| 11 |
license: apache-2.0
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
<p align="center">
|
| 18 |
-
<a href="https://huggingface.co/OpenMOSS-Team/MOSS-Image-Base"><img alt="Hugging Face · MOSS-Image-Base" src="https://img.shields.io/badge/🤗%20Hugging%20Face-MOSS--Image--Base-ffc107?style=flat-square"></a>
|
| 19 |
-
|
| 20 |
-
<a href="https://huggingface.co/OpenMOSS-Team/MOSS-Image-SFT"><img alt="Hugging Face · MOSS-Image-SFT" src="https://img.shields.io/badge/🤗%20Hugging%20Face-MOSS--Image--SFT-ffc107?style=flat-square"></a>
|
| 21 |
-
|
| 22 |
-
<a href="https://modelscope.cn/models/openmoss/MOSS-Image-Base"><img alt="ModelScope · MOSS-Image-Base" src="assets/modelscope-base-badge.svg"></a>
|
| 23 |
-
|
| 24 |
-
<a href="https://modelscope.cn/models/openmoss/MOSS-Image-SFT"><img alt="ModelScope · MOSS-Image-SFT" src="assets/modelscope-sft-badge.svg"></a>
|
| 25 |
-
|
| 26 |
-
<a href="https://github.com/OpenMOSS/MOSS-Image"><img alt="GitHub" src="https://img.shields.io/badge/GitHub-Code-181717?style=flat-square&logo=github&logoColor=white"></a>
|
| 27 |
-
|
| 28 |
-
<a href="https://openmoss.github.io/MOSS-Image/"><img alt="Homepage" src="https://img.shields.io/badge/🌐%20Project-Homepage-2563eb?style=flat-square"></a>
|
| 29 |
-
|
| 30 |
-
<a href="https://github.com/OpenMOSS/MOSS-Image/blob/main/paper/MOSS_Image_Technical_Report.pdf"><img alt="Technical Report" src="https://img.shields.io/badge/📄%20Paper-Technical_Report-b31b1b?style=flat-square"></a>
|
| 31 |
-
|
| 32 |
-
<a href="https://x.com/Open_MOSS"><img alt="Follow OpenMOSS on X" src="https://img.shields.io/badge/Follow-OpenMOSS-000000?style=flat-square&logo=x&logoColor=white"></a>
|
| 33 |
-
|
| 34 |
-
<a href="https://qm.qq.com/q/hphM7VhaDu"><img alt="MOSS-Image QQ 交流群:755535143" src="https://img.shields.io/badge/QQ-755535143-12B7F5?style=flat-square&logo=qq&logoColor=white"></a>
|
| 35 |
-
|
| 36 |
-
<a href="https://applink.feishu.cn/client/chat/chatter/add_by_link?link_token=7a3m2007-815f-409b-9c3d-a4129f5c058e"><img alt="MOSS-Builders Feishu Community" src="assets/feishu-builders-badge.svg"></a>
|
| 37 |
-
|
| 38 |
-
<a href="https://discord.gg/nXFWEyvbb"><img alt="MOSS-Image Discord Community" src="https://img.shields.io/badge/Discord-Community-5865F2?style=flat-square&logo=discord&logoColor=white"></a>
|
| 39 |
-
</p>
|
| 40 |
-
|
| 41 |
-
Gradio interface for [MOSS-Image](https://github.com/OpenMOSS/MOSS-Image),
|
| 42 |
-
including resolution and aspect-ratio presets, sampling controls, a selectable
|
| 43 |
-
example gallery, advanced guidance controls, and live example/default-prompt updates.
|
| 44 |
-
|
| 45 |
-
## Model loading
|
| 46 |
-
|
| 47 |
-
The Space preloads **MOSS-Image-Base** and **MOSS-Image-SFT** with
|
| 48 |
-
`snapshot_download(repo_id, revision=resolved_commit)`, followed by
|
| 49 |
-
`MOSSImagePipeline.from_pretrained(snapshot_path, local_files_only=True, ...)`.
|
| 50 |
-
The Space explicitly loads its bundled pipeline, transformer and scheduler classes
|
| 51 |
-
from `pipeline_moss_image.py` for the ZeroGPU AOT lifecycle. The bundled inference
|
| 52 |
-
implementation follows the current Base pipeline, including negative-branch skipping
|
| 53 |
-
and standard SLG. Progress is reported using the same bridge as the standalone app.
|
| 54 |
-
Weights are downloaded into the Hugging Face cache; no local model directory
|
| 55 |
-
or model weights in this repository are required.
|
| 56 |
-
|
| 57 |
-
Select **MOSS-Image-Base** or **MOSS-Image-SFT** in the Model dropdown before
|
| 58 |
-
clicking Generate. Base is selected by default. The optional `MOSS_MODEL_ID`
|
| 59 |
-
Space variable changes this initial selection.
|
| 60 |
-
|
| 61 |
-
Both transformers are loaded at startup. The text encoder, tokenizer and VAE
|
| 62 |
-
are each shared only when their Hub file hashes match at the resolved revisions.
|
| 63 |
-
Components that differ, such as model-specific VAEs, are loaded separately. Each model retains its own
|
| 64 |
-
scheduler, prompt cache and revision metadata. Generation requests run serially;
|
| 65 |
-
changing the dropdown does not change an already submitted request.
|
| 66 |
-
|
| 67 |
-
While the model repositories are private, configure an `HF_TOKEN` **Space secret**
|
| 68 |
-
with read access to both models. Do not put a token in source files or
|
| 69 |
-
ordinary Space variables. Local development uses the same environment variable
|
| 70 |
-
or your cached Hugging Face login.
|
| 71 |
-
|
| 72 |
-
## ZeroGPU
|
| 73 |
-
|
| 74 |
-
Both pipelines are loaded and placed on CUDA before the UI starts. Generation runs
|
| 75 |
-
under `@spaces.GPU(duration=80)`. At startup, a separate GPU allocation exports
|
| 76 |
-
and AOT-compiles the repeated DiT and text-projection blocks with dynamic sequence
|
| 77 |
-
lengths. Both models reuse the compiled graphs with their own weights. Compilation
|
| 78 |
-
is validated against eager block outputs before the UI starts. This uses ZeroGPU
|
| 79 |
-
AOTInductor support, not runtime `torch.compile`; GPU residency is fixed.
|
| 80 |
-
Set the Space variable `MOSS_AOTI=0` to run the eager baseline. Compilation happens
|
| 81 |
-
once per container start and is not part of image generation latency.
|
| 82 |
-
The 80-second budget is scaled to 120 seconds by the current RTX PRO 6000
|
| 83 |
-
ZeroGPU SDK configuration; it is not a measured latency guarantee.
|
| 84 |
-
Large images or batches may require more time or memory than the allocation allows.
|
| 85 |
-
|
| 86 |
-
Outputs and version-2 parameter JSON files are stored under `outputs/gradio/`. Records
|
| 87 |
-
include the model repository and resolved revision, actual seed, sampling
|
| 88 |
-
parameters, component configuration hashes, execution backend, and software versions. Space storage
|
| 89 |
-
is ephemeral; save generated images you want to keep.
|
| 90 |
-
|
| 91 |
-
## Local development
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
```bash
|
| 101 |
-
|
|
|
|
|
|
|
| 102 |
```
|
| 103 |
|
| 104 |
-
The
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
| 109 |
|
| 110 |
-
|
| 111 |
-
sharing and AOT compilation. Memory mode and runtime Compile DiT controls are not
|
| 112 |
-
shown because GPU residency and compilation are managed at startup. The generation
|
| 113 |
-
API returns the gallery and status, matching the standalone interface.
|
| 114 |
|
| 115 |
-
|
|
|
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
|
|
|
| 1 |
---
|
| 2 |
+
title: MOSS-Image Workflow
|
| 3 |
emoji: 🖼
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: indigo
|
|
|
|
| 7 |
sdk_version: 6.30.0
|
| 8 |
python_version: "3.12"
|
| 9 |
app_file: app.py
|
| 10 |
+
hf_oauth: true
|
| 11 |
+
hf_oauth_scopes:
|
| 12 |
+
- inference-api
|
| 13 |
+
- write-repos
|
| 14 |
pinned: false
|
| 15 |
license: apache-2.0
|
| 16 |
+
tags:
|
| 17 |
+
- ml-intern
|
| 18 |
+
short_description: MOSS-Image text-to-image as a gr.Workflow node canvas.
|
| 19 |
---
|
| 20 |
|
| 21 |
+
[](https://hf.co/chat?mode=ml-intern)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
# MOSS-Image Workflow
|
| 24 |
+
|
| 25 |
+
A [Gradio Workflow](https://www.gradio.app/guides/workflows) (node-canvas) version of the official
|
| 26 |
+
[OpenMOSS-Team/MOSS-Image](https://huggingface.co/spaces/OpenMOSS-Team/MOSS-Image) demo, built on
|
| 27 |
+
`gr.Workflow` in gradio 6.30.0, with the App view styled after the MOSS-Image landing page.
|
| 28 |
+
|
| 29 |
+
## Feature parity with the official demo
|
| 30 |
+
|
| 31 |
+
Every sampling control of the original Space is a reference node wired into the
|
| 32 |
+
`MOSS-Image Generate` function node:
|
| 33 |
+
|
| 34 |
+
| Original demo | Here |
|
| 35 |
+
|---|---|
|
| 36 |
+
| Model dropdown (Base / SFT) | **Model** reference (`base` or `sft`); both checkpoints loaded at startup |
|
| 37 |
+
| Prompt / Negative Prompt | **Prompt** / **Negative Prompt** references (same default text) |
|
| 38 |
+
| Width × Height (presets) | **Width** / **Height** references (multiples of 16) |
|
| 39 |
+
| Steps / CFG / Shift / Seed | **Steps** / **CFG** / **Shift** / **Seed** references (`-1` = random) |
|
| 40 |
+
| Images per prompt | **Images** reference → gallery output |
|
| 41 |
+
| Max text length | **Max Text Length** reference (1–4096) |
|
| 42 |
+
| Skip-layer modes (Off / Negative-branch skipping / Standard SLG) | **Skip Layers** (`22` = negative-branch skipping, empty = off), **SLG Layers**, **SLG Scale**, **Skip Start**, **Skip Stop** references |
|
| 43 |
+
| Example gallery with one-click restore | **Examples strip** under the hero: the original Space's 20 showcase images, hot-linked; clicking one fetches its `parameters.json` and restores prompt, model, size, sampling and SLG settings into the form |
|
| 44 |
|
| 45 |
+
Not ported: showcase add/delete with live refresh (the Workflow App view is
|
| 46 |
+
generated from the graph and has no upload-to-gallery mechanism), and ZeroGPU AOT
|
| 47 |
+
compilation (this app runs the eager backend — set it up like the original if you
|
| 48 |
+
need the extra speed).
|
| 49 |
+
|
| 50 |
+
## Design
|
| 51 |
+
|
| 52 |
+
The App view is auto-generated by `gr.Workflow`, so the landing-page look is applied
|
| 53 |
+
through `launch(theme=…, css=…, head=…)`: Inter type, a light gradient canvas, the
|
| 54 |
+
official MOSS-Image lockup (light/dark aware) above the
|
| 55 |
+
"Text-to-Image Generation with Native Layout Control" headline, a top nav with
|
| 56 |
+
model/code links, and a Soft blue theme. The canvas view is untouched.
|
| 57 |
+
|
| 58 |
+
## Running it
|
| 59 |
+
|
| 60 |
+
Generation runs on GPU via `@spaces.GPU(duration=80)` per node call, so this Space needs
|
| 61 |
+
**ZeroGPU hardware** (Settings → Hardware). `hf_oauth: true` is enabled so the owner can edit the
|
| 62 |
+
canvas and signed-in visitors spend their own ZeroGPU quota; anonymous visitors fall back to the
|
| 63 |
+
small shared allowance.
|
| 64 |
+
|
| 65 |
+
Local development:
|
| 66 |
|
| 67 |
```bash
|
| 68 |
+
pip install -r requirements.txt
|
| 69 |
+
python app.py # full run, needs a CUDA GPU
|
| 70 |
+
MOSS_WORKFLOW_PREVIEW=1 python app.py # canvas + styling only, no model download
|
| 71 |
```
|
| 72 |
|
| 73 |
+
The bundled `pipeline_moss_image.py` is copied verbatim from the
|
| 74 |
+
[original Space](https://huggingface.co/spaces/OpenMOSS-Team/MOSS-Image) (BSD 3-Clause); model
|
| 75 |
+
weights are Apache-2.0. The lockup artwork is hot-linked from the original Space's assets.
|
| 76 |
+
The form is prefilled with showcase example 007 (the photorealistic Kazusa at
|
| 77 |
+
a Tokyo crosswalk: 1184×1776, 50 steps, CFG 3, shift 5, skip layer 22, seed
|
| 78 |
+
3537712559) so visitors can just hit **Run** and reproduce it exactly. Other
|
| 79 |
+
defaults match the official demo: Euler sampling and negative-branch skipping.
|
| 80 |
|
| 81 |
+
## API example
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
+
```python
|
| 84 |
+
from gradio_client import Client
|
| 85 |
|
| 86 |
+
client = Client("akhaliq/moss-image-workflow")
|
| 87 |
+
client.view_api() # exact parameters of /generated_images
|
| 88 |
+
```
|