Run MOSS-Image-SFT for English and Chinese Text-to-Image
MOSS-Image-SFT is an Apache-2.0 text-to-image model from OpenMOSS with JSON layout control. Install it with diffusers and generate images with rendered text.
The code in this post comes from the model's docs and hasn't been run in our CI yet. If something breaks, let us know.
MOSS-Image-SFT is a supervised fine-tuned text-to-image model from OpenMOSS, derived from MOSS-Image-Base. It uses the same architecture and inference pipeline as the base model. What sets it apart is the prompt interface: besides natural-language prompts it accepts tag sequences and JSON layouts that control where text and objects go. The card says SFT produces “clearer text grouping and a more organized whiteboard layout” than Base in its comparison example. That is one example, not a benchmark.
Key specs
| Task | text-to-image |
| Library | diffusers (loaded via a custom pipeline) |
| Languages | English, Chinese |
| Base model | OpenMOSS-Team/MOSS-Image-Base (finetune) |
| Precision | Transformer and text encoder in bfloat16; VAE and initial noise in float32 |
| VAE | The bundled VAE uses the FLUX.2 small decoder |
| Default sampler | Flow-matching Euler, 50 steps, CFG 3, shift 5 |
| License | Apache 2.0 (weights and bundled inference code) |
The card doesn’t state a parameter count or a VRAM requirement, so check memory use on your own GPU.
Install
The card asks for Python 3.10 or later and an NVIDIA GPU with CUDA support. Install a PyTorch 2.9 or later build that matches your CUDA environment, then:
pip install "diffusers>=0.38" "transformers>=5.3" "accelerate>=1.10" "safetensors>=0.6" "Pillow>=10"Run it
This is the card’s quick-start example. The model and custom pipeline code are downloaded and cached automatically.
import torchfrom diffusers import DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained( "OpenMOSS-Team/MOSS-Image-SFT", custom_pipeline="pipeline_moss_image", trust_remote_code=True, torch_dtype={"default": torch.bfloat16, "vae": torch.float32},)pipe.scheduler = type(pipe.scheduler).from_config(pipe.scheduler.config)pipe.to("cuda")
prompt = '''A wide view of a refrigerator beside a kitchen counter with a fruit bowl. A small sticky note on the refrigerator door is handwritten in Chinese:"记得买牛奶和鸡蛋!牛奶两盒,鸡蛋一打。顺便带一袋面包。"'''
image = pipe( prompt, height=1024, width=1024, num_inference_steps=50, guidance_scale=3.0, uncond_skip_layers=[22], generator=torch.Generator("cpu").manual_seed(42),).images[0]image.save("refrigerator_note.png")trust_remote_code=True runs the pipeline code downloaded with the model, so read it first if you care about what runs on your machine. Image dimensions through the Python API must be positive multiples of 16.
Sampling settings
The card lists these defaults:
| Setting | Default |
|---|---|
| Sampler | Flow-matching Euler |
| Steps | 50 |
| CFG | 3 |
| Shift | 5 |
| Layer skipping | Negative branch, layer index 22 (zero-based) |
| Negative prompt | Empty |
The default guidance uses two transformer forwards per step. The card says you can pass uncond_skip_layers=[] to disable negative-branch skipping, or set negative_prompt to provide a negative prompt. The card sends resolution, sampling, prompt and LoRA training recommendations to the user guide.
Render text in a scene
The card’s own example is a Chinese handwritten note inside a scene, so rendered text is a core use case. To adapt it, put the exact text in quotes inside the prompt and describe where it appears, as the example does. This script reuses the same call with an English poster prompt of our own:
import torchfrom diffusers import DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained( "OpenMOSS-Team/MOSS-Image-SFT", custom_pipeline="pipeline_moss_image", trust_remote_code=True, torch_dtype={"default": torch.bfloat16, "vae": torch.float32},)pipe.scheduler = type(pipe.scheduler).from_config(pipe.scheduler.config)pipe.to("cuda")
prompt = '''A cafe chalkboard sign on a wooden table, handwritten in English:"Today's specialTomato soup and bread"'''
image = pipe( prompt, height=1024, width=1024, num_inference_steps=50, guidance_scale=3.0, uncond_skip_layers=[22], generator=torch.Generator("cpu").manual_seed(7),).images[0]image.save("chalkboard.png")The card gives no accuracy figures for text rendering, so inspect every output for misspellings.
Layout-to-image control
You can pass a JSON layout as the prompt to describe the scene, the rendered text, objects and their positions. According to the card:
- Layouts use
summary.captionanditems. - Boxes use
bbox_format: "yxyx"andbbox_coord_space: "abs_centralized". - With the Python API, serialize the layout with
json.dumps(layout, ensure_ascii=False)and pass the string topipe. - In the Gradio interface, paste the JSON into the Prompt field and set matching image dimensions.
The full layout format and an example are in the user guide, where the section is labeled experimental. The card says layouts can also support controlled editing: edit the text, element descriptions and bounding boxes to change the content and composition.
There is also a prompt enhancer skill that turns image ideas into detailed captions or Layout prompts. The card says it is designed for GPT-6-family agents with local file and Python tools, and that its script converts pixel-coordinate drafts into compact JSON; it does not call an image-generation service.
Gotchas
- NVIDIA/CUDA only in the card. The quick start requires a CUDA GPU. The card doesn’t document other backends.
- Dtype split. Keep the dtype dictionary from the example: bfloat16 for the transformer and text encoder, float32 for the VAE and initial noise.
- Two forwards per step. Default guidance runs the transformer twice per step, which affects speed.
- Remote code. The pipeline requires
trust_remote_code=True. - Multiples of 16. Height and width must be positive multiples of 16 in the Python API.
- Layout is experimental. The user guide labels layout prompts as experimental.
- Memory options. For CPU offload and compilation options, the card points to the project quick start.
- ComfyUI. Search for MOSS-Image in ComfyUI Manager for the native plugin. The card says integration into the official ComfyUI repository is in progress.
When to pick it
Pick MOSS-Image-SFT if you need an Apache-2.0 image model that you can run yourself, you work with English or Chinese text inside images, or you want to place elements with a structured layout. It is also a natural starting point if you plan to fine-tune with LoRA, since the project documents LoRA training in its user guide.
Skip it if you don’t have an NVIDIA GPU, if you need verified VRAM numbers before you start (the card gives none), or if you need benchmark evidence: the card contains a single Base versus SFT comparison image and no scores. If you want the untuned starting point, the card points to MOSS-Image-Base, which shares the same architecture and inference pipeline.
Related
Run Kromoss, a MOSS-Image Fine-Tune, with 8-Step Turbo LoRAs
Kromoss is an Apache-2.0 full fine-tune of MOSS-Image-Base at 1024 px. Run it with diffusers, and cut sampling to 8 steps with the bundled LoRAs.
lodestones/Kromoss
Run MiniMax-H3-Image for 16-Megapixel Text-to-Image and Editing
MiniMax-H3-Image generates and edits images up to about 16 MP in 6 sampling steps. Serve it with vLLM-Omni or SGLang and call its image endpoints.
MiniMaxAI/MiniMax-H3-Image
Generate, Edit and Make Transparent Images with Qwen-Image-2.1
Qwen-Image-2.1 combines text-to-image, image editing and native RGBA output in one diffusers pipeline. Here is how to run it.
Qwen/Qwen-Image-2.1