akhaliq's picture
akhaliq HF Staff
Full space card: ZeroGPU enablement, controls, implementation notes
de5c408 verified
|
Raw History Blame Contribute Delete
6.16 kB

A newer version of the Gradio SDK is available: 6.33.0

Upgrade
metadata
title: Ming Image Layer Decomposition Studio
emoji: 🧩
colorFrom: purple
colorTo: green
sdk: gradio
sdk_version: 6.17.3
app_file: app.py
python_version: '3.12'
pinned: false
startup_duration_timeout: 1h
short_description: Editable RGBA layer decomposition with Ming Design-Layer
tags:
  - ml-intern
  - layer-decomposition
  - rgba
  - graphic-design
  - ming-image
models:
  - inclusionAI/Ming-Image-0.2-Design-Layer

Ming Image · Layer Decomposition Studio

A Gradio Server and Workflow interface for inclusionAI/Ming-Image-0.2-Design-Layer, focused on editable RGBA layer decomposition: general design layers, 2D character-rigging parts in front-to-back occlusion order, and bounding-box-guided extraction. It mirrors the structure of inclusionAI/ming-image-0-2-design, adapted to this checkpoint's layer-decompose task.

App views

  • / — Studio: an original responsive frontend with drag-and-drop input, the three official sample images and their prompts (design, character rigging, bounding boxes), working-resolution and sampling controls, a transparency-aware result stage, per-layer PNG download, session history, and dark/light themes. It calls the queued Gradio Server /decompose API.
  • /workflow — Workflow: a typed node canvas with an Input Image reference plus Resolution, Steps, CFG, Seed, Layer Count, and optional Layer Spec references feeding one Ming Decompose operator and a Reconstructed Composite subject. Edit workflow.json to change the starter graph.

Enable generation

This Space is initially deployed on free CPU hardware. To run the model:

  1. Open Settings → Hardware for this Space.
  2. Select ZeroGPU and restart the Space.
  3. Wait for the first model load. The BF16 checkpoint is approximately 53 GB, so initial download and startup can take some time.

The Decompose function already uses @spaces.GPU(size="xlarge"), which requests a full 96 GB ZeroGPU worker. This is required rather than the default 48 GB worker because the authors validate the model on an 80 GiB GPU. On plain CPU, the app does not download the checkpoint and displays a hardware instruction if decomposition is attempted.

Controls

  • Input image: any PNG, JPEG, or WebP, downscaled to 1600 px on the long side before the run. The output preserves the input's aspect ratio.
  • Working resolution: the 512 or 1024 bucket, as validated by the authors.
  • Layer specification: optional. When empty, the app sends Decompose this image into N layers. with the chosen count (1–12, default 5). When filled, the Number of layers: line in the spec controls the count. Character-rigging specs follow the official prompt rewriter format; bounding boxes use normalized 0–999 xyxy coordinates on a 1000×1000 scale and need no prompt rewriting.
  • Sampling: 12 steps and CFG 2.0 by default, as recommended by the model card.
  • Seed: fixed for reproducibility or randomized per request.
  • Samples: populate the input and spec only; no example decomposition or caching runs during startup.

Implementation

Unlike a standard Diffusers pipeline, this checkpoint is a package containing a BailingMoE prompt encoder, connector, learned projections, a 6B flow-matching DiT, and a four-channel RGBA VAE. The app therefore calls the authors' own load_model_and_processor() and run_generation() functions from inclusionAI/Ming-Image, pinned to commit 041945f5c36d20cbf0fc6debc0a810a747e19644, with the layer-decompose task, num_layers + 1 output frames (composite first, layers after), and the RGBA reference-image mode this checkpoint's profile declares. The source archive is downloaded only when a CUDA runtime is initialized.

When ZeroGPU exposes its CUDA emulation at module scope, the model loads eagerly at startup as recommended by the ZeroGPU documentation. Plain CPU skips loading; a guarded lazy fallback covers other environments. Decomposition uses one process-wide engine and a queue.

Dependency notes

Transformers 4.57.1 and Diffusers 0.36.0 follow the official Ming dependency stack. Gradio is pinned to 6.17.3 because it includes gr.Server and gr.Workflow while retaining a huggingface-hub<2 range compatible with Transformers 4.57.1's huggingface-hub<1 requirement. Gradio 6.18 and newer require Hub 1.x, so they cannot share this environment with the official Ming stack. Torch 2.8.0 is the oldest PyTorch release supported by current ZeroGPU, with matching Torchvision 0.23.0. NumPy is raised from the official 1.23.1 pin because that release does not support Python 3.12. Transformer Engine and FlashAttention are not installed: the official code makes Transformer Engine optional, and this app uses eager attention.

Model weights are MIT licensed; see the model card.