Duplicate from DiffSynth-Studio/Qwen-Image-Layered-Control
Browse filesCo-authored-by: kelseye.xh <kelseye@users.noreply.huggingface.co>
Files changed (30)
- .gitattributesAdded+54
- README.mdAdded+136
- README_from_modelscope.mdAdded+144
- assets/image_1_0_0.pngAdded
- assets/image_1_1_0.pngAdded
- assets/image_1_2_0.pngAdded
- assets/image_1_3_0.pngAdded
- assets/image_1_4_0.pngAdded
- assets/image_1_5_0.pngAdded
- assets/image_1_6_0.pngAdded
- assets/image_1_7_0.pngAdded
- assets/image_1_input.pngAdded
- assets/image_2_0_0.pngAdded
- assets/image_2_1_0.pngAdded
- assets/image_2_2_0.pngAdded
- assets/image_2_3_0.pngAdded
- assets/image_2_input.pngAdded
- assets/image_3_0_0.pngAdded
- assets/image_3_1_0.pngAdded
- assets/image_3_2_0.pngAdded
- assets/image_3_3_0.pngAdded
- assets/image_3_input.pngAdded
- configuration.jsonAdded+1
- qwen_image_layered_control_bf16.safetensorsAdded+3
- transformer/config.jsonAdded+20
- transformer/diffusion_pytorch_model-00001-of-00005.safetensorsAdded+3
- transformer/diffusion_pytorch_model-00002-of-00005.safetensorsAdded+3
- transformer/diffusion_pytorch_model-00003-of-00005.safetensorsAdded+3
- transformer/diffusion_pytorch_model-00004-of-00005.safetensorsAdded+3
- transformer/diffusion_pytorch_model-00005-of-00005.safetensorsAdded+3
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354*.7z filter=lfs diff=lfs merge=lfs -text*.arrow filter=lfs diff=lfs merge=lfs -text*.bin filter=lfs diff=lfs merge=lfs -text*.bz2 filter=lfs diff=lfs merge=lfs -text*.ckpt filter=lfs diff=lfs merge=lfs -text*.ftz filter=lfs diff=lfs merge=lfs -text*.gz filter=lfs diff=lfs merge=lfs -text*.h5 filter=lfs diff=lfs merge=lfs -text*.joblib filter=lfs diff=lfs merge=lfs -text*.lfs.* filter=lfs diff=lfs merge=lfs -text*.mlmodel filter=lfs diff=lfs merge=lfs -text*.model filter=lfs diff=lfs merge=lfs -text*.msgpack filter=lfs diff=lfs merge=lfs -text*.npy filter=lfs diff=lfs merge=lfs -text*.npz filter=lfs diff=lfs merge=lfs -text*.onnx filter=lfs diff=lfs merge=lfs -text*.ot filter=lfs diff=lfs merge=lfs -text*.parquet filter=lfs diff=lfs merge=lfs -text*.pb filter=lfs diff=lfs merge=lfs -text*.pickle filter=lfs diff=lfs merge=lfs -text*.pkl filter=lfs diff=lfs merge=lfs -text*.pt filter=lfs diff=lfs merge=lfs -text*.pth filter=lfs diff=lfs merge=lfs -text*.rar filter=lfs diff=lfs merge=lfs -text*.safetensors filter=lfs diff=lfs merge=lfs -textsaved_model/**/* filter=lfs diff=lfs merge=lfs -text*.tar.* filter=lfs diff=lfs merge=lfs -text*.tar filter=lfs diff=lfs merge=lfs -text*.tflite filter=lfs diff=lfs merge=lfs -text*.tgz filter=lfs diff=lfs merge=lfs -text*.wasm filter=lfs diff=lfs merge=lfs -text*.xz filter=lfs diff=lfs merge=lfs -text*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textassets/image_1_0_0.png filter=lfs diff=lfs merge=lfs -textassets/image_1_1_0.png filter=lfs diff=lfs merge=lfs -textassets/image_1_2_0.png filter=lfs diff=lfs merge=lfs -textassets/image_1_3_0.png filter=lfs diff=lfs merge=lfs -textassets/image_1_4_0.png filter=lfs diff=lfs merge=lfs -textassets/image_1_5_0.png filter=lfs diff=lfs merge=lfs -textassets/image_1_6_0.png filter=lfs diff=lfs merge=lfs -textassets/image_1_7_0.png filter=lfs diff=lfs merge=lfs -textassets/image_1_input.png filter=lfs diff=lfs merge=lfs -textassets/image_2_0_0.png filter=lfs diff=lfs merge=lfs -textassets/image_2_1_0.png filter=lfs diff=lfs merge=lfs -textassets/image_2_2_0.png filter=lfs diff=lfs merge=lfs -textassets/image_2_3_0.png filter=lfs diff=lfs merge=lfs -textassets/image_2_input.png filter=lfs diff=lfs merge=lfs -textassets/image_3_0_0.png filter=lfs diff=lfs merge=lfs -textassets/image_3_1_0.png filter=lfs diff=lfs merge=lfs -textassets/image_3_2_0.png filter=lfs diff=lfs merge=lfs -textassets/image_3_3_0.png filter=lfs diff=lfs merge=lfs -textassets/image_3_input.png filter=lfs diff=lfs merge=lfs -text123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136---license: apache-2.0---# Qwen-Image-Layered
## Model Introduction
This model is trained based on the model [Qwen/Qwen-Image-Layered](https://modelscope.cn/models/Qwen/Qwen-Image-Layered) using the dataset [artplus/PrismLayersPro](https://modelscope.cn/datasets/artplus/PrismLayersPro), enabling text-controlled extraction of segmented layers.
For more details about training strategies and implementation, feel free to check our [technical blog](https://modelscope.cn/learn/4938).
## Usage Tips
* The model architecture has been changed from multi-image output to single-image output, producing only the layer relevant to the provided text description.* The model was trained exclusively on English text, but retains Chinese language understanding capabilities inherited from the base model.* The native training resolution is 1024x1024; however, inference at other resolutions is supported.* The model struggles to separate multiple entities that are heavily occluded or overlapping, such as the cartoon skeleton head and hat in the examples.* The model excels at decomposing poster-like graphics but performs poorly on photographic images, especially those involving complex lighting and shadows.* The model supports negative prompts—users can specify content they wish to exclude via negative prompt descriptions.
## Demo Examples
**Some images contain white text on light backgrounds. ModelScope users should click the "☀︎" icon in the top-right corner to switch to dark mode for better visibility.**
### Example 1
<div style="display: flex; justify-content: space-between;">
<div style="width: 30%;">
|Input Image||-|||
</div>
<div style="width: 66%;">
|Prompt|Output Image|Prompt|Output Image||-|-|-|-||A solid, uniform color with no distinguishable features or objects||Text 'TRICK'|||Cloud||Text 'TRICK OR TREAT'|||A cartoon skeleton character wearing a purple hat and holding a gift box||Text 'TRICK OR'|||A purple hat and a head||A gift box||
</div>
</div>
### Example 2
<div style="display: flex; justify-content: space-between;">
<div style="width: 30%;">
|Input Image||-|||
</div>
<div style="width: 66%;">
|Prompt|Output Image|Prompt|Output Image||-|-|-|-||Blue sky, white clouds, a garden with colorful flowers||Colorful, intricate floral wreath|||Girl, wreath, kitten||Girl, kitten||
</div>
</div>
### Example 3
<div style="display: flex; justify-content: space-between;">
<div style="width: 30%;">
|Input Image||-|||
</div>
<div style="width: 66%;">
|Prompt|Output Image|Prompt|Output Image||-|-|-|-||A clear blue sky and a turbulent sea||Text "The Life I Long For"|||A seagull||Text "Life"||
</div>
</div>
## Inference Code
Install DiffSynth-Studio:
```git clone https://github.com/modelscope/DiffSynth-Studio.git cd DiffSynth-Studiopip install -e .```
Model inference:
```pythonfrom diffsynth.pipelines.qwen_image import QwenImagePipeline, ModelConfigfrom PIL import Imageimport torch, requests
pipe = QwenImagePipeline.from_pretrained( torch_dtype=torch.bfloat16, device="cuda", model_configs=[ ModelConfig(model_id="DiffSynth-Studio/Qwen-Image-Layered-Control", origin_file_pattern="transformer/diffusion_pytorch_model*.safetensors"), ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="text_encoder/model*.safetensors"), ModelConfig(model_id="Qwen/Qwen-Image-Layered", origin_file_pattern="vae/diffusion_pytorch_model.safetensors"), ], processor_config=ModelConfig(model_id="Qwen/Qwen-Image-Edit", origin_file_pattern="processor/"),)prompt = "A cartoon skeleton character wearing a purple hat and holding a gift box"input_image = requests.get("https://modelscope.oss-cn-beijing.aliyuncs.com/resource/images/trick_or_treat.png", stream=True).rawinput_image = Image.open(input_image).convert("RGBA").resize((1024, 1024))input_image.save("image_input.png")images = pipe( prompt, seed=0, num_inference_steps=30, cfg_scale=4, height=1024, width=1024, layer_input_image=input_image, layer_num=0,)images[0].save("image.png")```123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144---frameworks: PyTorchlicense: Apache License 2.0tags: []tasks: - text-to-image-synthesisbase_model: - Qwen/Qwen-Image-Layeredbase_model_relation: finetune---# Qwen-Image-Layered
## 模型介绍
本模型基于模型 [Qwen/Qwen-Image-Layered](https://modelscope.cn/models/Qwen/Qwen-Image-Layered) 在数据集 [artplus/PrismLayersPro](https://modelscope.cn/datasets/artplus/PrismLayersPro) 上进行了训练,可以通过文本控制拆分的图层内容。
更多关于训练策略和实现细节,欢迎查看我们的[技术博客](https://modelscope.cn/learn/4938)。
## 使用技巧
* 模型结构从多图输出改为了单图输出,仅输出与文本描述相关的图层* 模型只用英文文本训练过,但仍从基础模型继承了中文理解能力* 模型训练的原生分辨率是1024x1024,支持以其他分辨率进行推理* 模型难以拆分“互相遮挡”的多个实体,例如样例中的卡通骷髅头和帽子* 模型擅长拆分海报图层,不擅长拆分摄影图像,尤其是存在光影的照片* 模型支持负向提示词,可以通过负向提示词描述不希望出现在结果的内容
## 效果展示
**部分图片为纯白色文本,魔搭社区用户请点击页面右上角的“☀︎”切换到暗色模式**
### 样例1
<div style="display: flex; justify-content: space-between;">
<div style="width: 30%;">
|输入图||-|||
</div>
<div style="width: 66%;">
|提示词|输出图|提示词|输出图||-|-|-|-||A solid, uniform color with no distinguishable features or objects||Text 'TRICK'|||Cloud||Text 'TRICK OR TREAT'|||A cartoon skeleton character wearing a purple hat and holding a gift box||Text 'TRICK OR'|||A purple hat and a head||A gift box||
</div>
</div>
### 样例2
<div style="display: flex; justify-content: space-between;">
<div style="width: 30%;">
|输入图||-|||
</div>
<div style="width: 66%;">
|提示词|输出图|提示词|输出图||-|-|-|-||蓝天,白云,一片花园,花园里有五颜六色的花||五彩的精致花环|||少女、花环、小猫||少女、小猫||
</div>
</div>
### 样例3
<div style="display: flex; justify-content: space-between;">
<div style="width: 30%;">
|输入图||-|||
</div>
<div style="width: 66%;">
|提示词|输出图|提示词|输出图||-|-|-|-||一片湛蓝的天空和波涛汹涌的大海||文字“向往的生活”|||一只海鸥||文字“生活”||
</div>
</div>
## 推理代码
安装 DiffSynth-Studio:
```git clone https://github.com/modelscope/DiffSynth-Studio.git cd DiffSynth-Studiopip install -e .```
模型推理:
```pythonfrom diffsynth.pipelines.qwen_image import QwenImagePipeline, ModelConfigfrom PIL import Imageimport torch, requests
pipe = QwenImagePipeline.from_pretrained( torch_dtype=torch.bfloat16, device="cuda", model_configs=[ ModelConfig(model_id="DiffSynth-Studio/Qwen-Image-Layered-Control", origin_file_pattern="transformer/diffusion_pytorch_model*.safetensors"), ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="text_encoder/model*.safetensors"), ModelConfig(model_id="Qwen/Qwen-Image-Layered", origin_file_pattern="vae/diffusion_pytorch_model.safetensors"), ], processor_config=ModelConfig(model_id="Qwen/Qwen-Image-Edit", origin_file_pattern="processor/"),)prompt = "A cartoon skeleton character wearing a purple hat and holding a gift box"input_image = requests.get("https://modelscope.oss-cn-beijing.aliyuncs.com/resource/images/trick_or_treat.png", stream=True).rawinput_image = Image.open(input_image).convert("RGBA").resize((1024, 1024))input_image.save("image_input.png")images = pipe( prompt, seed=0, num_inference_steps=30, cfg_scale=4, height=1024, width=1024, layer_input_image=input_image, layer_num=0,)images[0].save("image.png")```1{"framework":"Pytorch","task":"text-to-image-synthesis"}123version https://git-lfs.github.com/spec/v1oid sha256:63b1966f0423bdc94d87273b8958de91e0a8f642c635f9113632d09cae3aa4adsize 408610438881234567891011121314151617181920{ "_class_name": "QwenImageTransformer2DModel", "_diffusers_version": "0.36.0.dev0", "use_additional_t_cond": true, "attention_head_dim": 128, "axes_dims_rope": [ 16, 56, 56 ], "guidance_embeds": false, "in_channels": 64, "joint_attention_dim": 3584, "num_attention_heads": 24, "num_layers": 60, "out_channels": 16, "patch_size": 2, "use_layer3d_rope": true, "zero_cond_t": false}123version https://git-lfs.github.com/spec/v1oid sha256:e5353f1dbff8445840012bd2aff2fd209034aa42d0ce623a55f3f542036244a2size 9973590960123version https://git-lfs.github.com/spec/v1oid sha256:957d266a7ccdcc9d3f225c82b0afa831ba5084c851b86934b9e4e9f10163b985size 9987326040123version https://git-lfs.github.com/spec/v1oid sha256:1f0e2bec2869de66f02b53bda77bc11618aba229453be56170209a654ddff0c0size 9987307408123version https://git-lfs.github.com/spec/v1oid sha256:5244cf56dd45667fc8f373d43550bc187909bc48489f380fa3dcbb02901e7dcfsize 9930685680123version https://git-lfs.github.com/spec/v1oid sha256:45ecb944aad539ceaae9e3ba99dc9f2d650ba034cf4b305b0e83ebce0bb7b55csize 982130448.gitattributesAdded+54
README.mdAdded+136
README_from_modelscope.mdAdded+144
assets/image_1_0_0.pngAdded

Large File Pointer Details
- SHA256: 7571c7a59e6a301c2909978baeffa4c2d25aa31103dc026e702e6e0b77f4d545
- Pointer size: 131 Bytes
- Size of remote file: 766 kB
assets/image_1_1_0.pngAdded

Large File Pointer Details
- SHA256: cf931fc683c3b51aea11d0cc18bcb3e108fea6e157a60f9aa64d3e9316edb67b
- Pointer size: 131 Bytes
- Size of remote file: 764 kB
assets/image_1_2_0.pngAdded

Large File Pointer Details
- SHA256: e5e1e50a3549c9a88fac681ede16d5682e6bfc52bc584276fef9fd4b1439dda8
- Pointer size: 131 Bytes
- Size of remote file: 880 kB
assets/image_1_3_0.pngAdded

Large File Pointer Details
- SHA256: 695c67883053681cbde394e0189cfc31c2a45d5c9b44887e9872dca8b4ec20b3
- Pointer size: 131 Bytes
- Size of remote file: 720 kB
assets/image_1_4_0.pngAdded

Large File Pointer Details
- SHA256: fb02a4888540a023af32cb13c52f8883bc83f436544a3d9dec3c07a9c59578ca
- Pointer size: 131 Bytes
- Size of remote file: 650 kB
assets/image_1_5_0.pngAdded

Large File Pointer Details
- SHA256: 9cc2f7958c5c27cdefa7309112d831435ac5b05d075bde7b4a6571e6a81e5f40
- Pointer size: 131 Bytes
- Size of remote file: 714 kB
assets/image_1_6_0.pngAdded

Large File Pointer Details
- SHA256: 8c243e61ce6f592e936013fa33c8825edf544a9ddc31cdf3e65a7fedfc857741
- Pointer size: 131 Bytes
- Size of remote file: 637 kB
assets/image_1_7_0.pngAdded

Large File Pointer Details
- SHA256: a15ad9e370a58b5e77f608affaf44870888e0081a2294f04119ca98131561ea4
- Pointer size: 131 Bytes
- Size of remote file: 660 kB
assets/image_1_input.pngAdded

Large File Pointer Details
- SHA256: 0bf0cf15ba21de772f11eb11bf9fa9f62a4d2467347c98559b1d257220bd50ef
- Pointer size: 131 Bytes
- Size of remote file: 902 kB
assets/image_2_0_0.pngAdded

Large File Pointer Details
- SHA256: f72f561ea8b1a20ab9215ef1285d5a767867d63a79b8384cdcb65ab281e3cca5
- Pointer size: 132 Bytes
- Size of remote file: 1.11 MB
assets/image_2_1_0.pngAdded

Large File Pointer Details
- SHA256: 21615ea7ff938ba73922c36daac996da4efa97984bfd72f42c4cab73c04e864a
- Pointer size: 132 Bytes
- Size of remote file: 1.27 MB
assets/image_2_2_0.pngAdded

Large File Pointer Details
- SHA256: f387a8f1646ce99b06156596fa0210fdfbb5b71c349427eb8e848b2722bfe569
- Pointer size: 131 Bytes
- Size of remote file: 761 kB
assets/image_2_3_0.pngAdded

Large File Pointer Details
- SHA256: 149bc856488fe40d485d93e5788c3ea66ebab22cf0faa5bd5b11e10080602441
- Pointer size: 132 Bytes
- Size of remote file: 1.17 MB
assets/image_2_input.pngAdded

Large File Pointer Details
- SHA256: ba1980967215c5090e26673dd38805b6d140662a9fff6f4e3fe2422485723c9a
- Pointer size: 132 Bytes
- Size of remote file: 1.32 MB
assets/image_3_0_0.pngAdded

Large File Pointer Details
- SHA256: bcebe462984c8df120eddc998f7277f3c226dd717d3270b9b0cdba9154d5b65e
- Pointer size: 132 Bytes
- Size of remote file: 1.31 MB
assets/image_3_1_0.pngAdded

Large File Pointer Details
- SHA256: fac7be288f3c4ead811edc2a388651424a07ac5ce6ef9f278af0861589bf5c01
- Pointer size: 131 Bytes
- Size of remote file: 613 kB
assets/image_3_2_0.pngAdded

Large File Pointer Details
- SHA256: 168cff1bc58b7ef2e98dee24686ec9cf4923c79910c5728a3c0366307fbe5214
- Pointer size: 131 Bytes
- Size of remote file: 671 kB
assets/image_3_3_0.pngAdded

Large File Pointer Details
- SHA256: e8e98774b8dd5afad15d12ef7f5895c5b0280391f6f26b4a8ec736356c602e49
- Pointer size: 131 Bytes
- Size of remote file: 627 kB
assets/image_3_input.pngAdded

Large File Pointer Details
- SHA256: 17af2255d4311cc9a9bf96b3c5650a7754a74ccbb6fc677487f5c16de7264d91
- Pointer size: 132 Bytes
- Size of remote file: 1.37 MB
configuration.jsonAdded+1
qwen_image_layered_control_bf16.safetensorsAdded+3
transformer/config.jsonAdded+20
transformer/diffusion_pytorch_model-00001-of-00005.safetensorsAdded+3
transformer/diffusion_pytorch_model-00002-of-00005.safetensorsAdded+3
transformer/diffusion_pytorch_model-00003-of-00005.safetensorsAdded+3
transformer/diffusion_pytorch_model-00004-of-00005.safetensorsAdded+3
transformer/diffusion_pytorch_model-00005-of-00005.safetensorsAdded+3