# H3-image-WYW-OiiB-1.0
## 模型介绍
本模型依托魔搭社区(ModelScope)AIGC专区[模型训练](https://modelscope.cn/aigc/modelTraining)环境与算力完成训练。
* 模型类型:LoRA
* 基础模型:[MiniMax/MiniMax-H3-Image](https://modelscope.cn/models/MiniMax/MiniMax-H3-Image)
* 训练代码:[DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio)
* 训练数据量:35
* 总训练步数:1000
* 开源协议:Apache-2.0
## 推理代码
安装 [DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio):
```bash
pip install diffsynth
```
开始推理:
```python
import torch
from diffsynth.pipelines.minimax_h3_image import MiniMaxH3ImagePipeline, ModelConfig
from diffsynth.core.quant import QuantizeConfig
offload_vram_config = {
"offload_dtype": "disk",
"offload_device": "disk",
"onload_dtype": "disk",
"onload_device": "disk",
"preparing_dtype": torch.bfloat16,
"preparing_device": "cuda",
"computation_dtype": torch.bfloat16,
"computation_device": "cuda",
}
quant_vram_config = {
"offload_dtype": torch.bfloat16,
"offload_device": "cpu",
"onload_dtype": torch.bfloat16,
"onload_device": "cpu",
"preparing_dtype": torch.bfloat16,
"preparing_device": "cuda",
"computation_dtype": torch.bfloat16,
"computation_device": "cuda",
"quantize": QuantizeConfig(method="entropack_lossy_quant_int8_raw"),
}
pipe = MiniMaxH3ImagePipeline.from_pretrained(
torch_dtype=torch.bfloat16,
device="cuda",
model_configs=[
ModelConfig(model_id="MiniMax/MiniMax-H3", origin_file_pattern="FL2VA/text_encoder/model*.safetensors", **offload_vram_config),
ModelConfig(model_id="MiniMax/MiniMax-H3-Image", origin_file_pattern="transformer/model*.safetensors", **quant_vram_config),
ModelConfig(model_id="MiniMax/MiniMax-H3-Image", origin_file_pattern="pdd_fused_heads.safetensors", **quant_vram_config),
ModelConfig(model_id="MiniMax/MiniMax-H3-Image", origin_file_pattern="vae/diffusion_pytorch_model.safetensors", **offload_vram_config),
],
processor_config=ModelConfig(model_id="MiniMax/MiniMax-H3-Image", origin_file_pattern="processor/"),
vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 2,
)
pipe.load_lora(pipe.dit, ModelConfig(model_id="zyyw1022/H3-image-WYW-OiiB-1.0", origin_file_pattern="H3-image-WYW-OiiB-1.0_c1-st1000.safetensors"))
prompt = "a cat"
image = pipe(prompt=prompt, height=2048, width=2048, seed=0)
image.save("image.jpg")
```
