# 3D动画、人物肖像
本模型使用 [**Qwen-Image-i2L**](https://modelscope.ai/models/DiffSynth-Studio/Qwen-Image-i2L) 从 2 张图像生成。
## 安装
```bash
git clone https://github.com/modelscope/DiffSynth-Studio.git
cd DiffSynth-Studio
pip install -e .
```
## 使用本模型
```python
from modelscope import snapshot_download
from diffsynth.pipelines.qwen_image import QwenImagePipeline, ModelConfig
import torch
vram_config = {
"offload_dtype": "disk",
"offload_device": "disk",
"onload_dtype": torch.bfloat16,
"onload_device": "cpu",
"preparing_dtype": torch.bfloat16,
"preparing_device": "cuda",
"computation_dtype": torch.bfloat16,
"computation_device": "cuda",
}
pipe = QwenImagePipeline.from_pretrained(
torch_dtype=torch.bfloat16,
device="cuda",
model_configs=[
ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="transformer/diffusion_pytorch_model*.safetensors", **vram_config),
ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="text_encoder/model*.safetensors", **vram_config),
ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="vae/diffusion_pytorch_model.safetensors", **vram_config),
],
tokenizer_config=ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="tokenizer/"),
vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 0.5,
)
lora_path = snapshot_download(model_id="diffsynth-i2L-gallery/Qwen-Image-3Danimation-portrait-5a2b")
pipe.load_lora(pipe.dit, f"{lora_path}/model.safetensors")
image = pipe("一位非洲裔女性3D动画角色,面带微笑,穿着职业装或传统印花服饰,背景为纯色简洁影棚风格", seed=0, height=1024, width=1024, num_inference_steps=50)
image.save("image.jpg")
```
## 相关链接
- i2L 模型:https://modelscope.ai/models/DiffSynth-Studio/Qwen-Image-i2L
- 代码仓库:https://github.com/modelscope/DiffSynth-Studio
## License
Apache-2.0
Description
本模型由 Image-to-LoRA 模型生成:https://modelscope.ai/models/DiffSynth-Studio/Qwen-Image-i2L
