Files
majicflus_v1/README.md
2025-02-08 05:46:51 +00:00

142 lines
5.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
frameworks:
- Pytorch
license: Apache License 2.0
tags:
- Checkpoint
- text-to-image
tasks:
- text-to-image-synthesis
vision_foundation: FLUX_1
base_model:
- black-forest-labs/FLUX.1-dev
---
麦橘超然 MajicFlus 是一款基于 [flux.dev](https://www.modelscope.cn/models/black-forest-labs/FLUX.1-dev) 微调融合的模型,专注于高质量人像生成,尤其擅长表现 亚洲女性 的细腻与美感。模型以 **唯美、写实、易用** 为核心特色,能够通过简单的提示词生成优质效果,同时对复杂提示词也有出色的响应能力。
## 模型特点
- 卓越的人像生成能力: 优化了在不同光影条件下的表现,确保人像在各种构图中的 面部细节 和 肢体完整性。
- 广泛的适用性: 除了人像生成外,模型在生成 非人生物 和 场景 时也有显著改进,适应更多创作需求。
- 简单易用: 用户无需复杂的提示词即可生成高质量作品,同时支持更长提示词的精细控制。
## 社区适配
MajicFlus 模型在发布的同时,多位社区成员基于模型制作的 LoRA 也将一同发布,进一步扩展了模型的功能与表现力。这些 LoRA 为用户提供了更多样化的创作可能性,使模型能够适应更多特定场景和风格需求。
## 弱点
- MajicFlus 并非为生成 NSFW 内容而设计。然而,如果有需要,可以使用相关 LoRA 来实现此类目的。
- MajicFlus 的存在是为了解决国际社区中模型缺乏亚洲代表性的问题。如果您希望生成非亚洲种族的图像,请考虑使用其他高质量模型。
- 由于该模型是个微调融合模型对社区大部分的lora都是不完美兼容的需要降低权重至0.5以下。推荐使用带有majicFlus标志的矩阵模型搜索关键字majic并筛选f1模型就可以看到全部现在已有超过50款风格各异的优质模型。
## 参数推荐 Parameter
- Steps: 20~30
- Distilled CFG Scale: 3.5
- CFG : 1
- Diffusion in Low Bits: float8-e4m3fn
- Sampling: Euler + simple/beta (for general)DPM2M + SGM uniform (for skin texture)DEIS + DDIM uniform (for casual realistic look)
- Vae: flux vae
- Clip: clip_l.safetensors and t5xxl_fp8_e4m3fn.safetensors
## 生图
本模型可通过[AIGC专区生图](https://www.modelscope.cn/aigc/imageGeneration?tab=advanced&versionId=14497&modelType=Checkpoint&sdVersion=FLUX_1&modelUrl=modelscope%3A%2F%2FMAILAND%2Fmajicflus_v1%3Frevision%3Dv1.0)直接在线使用。也通过ModelScope API-Inference使用见本页面右侧
如果要下载模型到本地进行推理生图需要结合原始FLUX模型的vae等模块可以使用DiffSynth-Studio封装好的生图pipeline。
### 安装DiffSynth
```
pip install diffsynth -U
```
### 推理生图
#### 量化推理(需要至少 14G 显存)
推荐方式,能在较小显存下,实现无损生图。需要较大的内存来支持模型不同模块的逐个加载。
```python
import torch
from modelscope import snapshot_download
from diffsynth import ModelManager, FluxImagePipeline
# 下载模型
snapshot_download(
model_id="MAILAND/majicflus_v1",
allow_file_pattern="majicflus_v134.safetensors",
cache_dir="models"
)
snapshot_download(
model_id="black-forest-labs/FLUX.1-dev",
allow_file_pattern=["ae.safetensors", "text_encoder/model.safetensors", "text_encoder_2/*"],
cache_dir="models"
)
# 设置推理计算精度为 bfloat16
model_manager = ModelManager(torch_dtype=torch.bfloat16)
# 以 float8 精度加载 DiT 部分
model_manager.load_models(
["models/MAILAND/majicflus_v1/majicflus_v134.safetensors"],
torch_dtype=torch.float8_e4m3fn,
device="cpu"
)
# 以 bfloat16 精度加载两个 Text Encoder 和 VAE
model_manager.load_models(
[
"models/black-forest-labs/FLUX.1-dev/text_encoder/model.safetensors",
"models/black-forest-labs/FLUX.1-dev/text_encoder_2",
"models/black-forest-labs/FLUX.1-dev/ae.safetensors",
],
torch_dtype=torch.bfloat16,
device="cpu"
)
# 开启量化与显存管理
pipe = FluxImagePipeline.from_model_manager(model_manager, device="cuda")
pipe.enable_cpu_offload()
pipe.dit.quantize()
# 生图!
image = pipe(prompt="a beautiful girl", seed=0)
image.save("image.jpg")
```
#### 原生精度推理(需要至少 40G 显存)
```python
import torch
from modelscope import snapshot_download
from diffsynth import ModelManager, FluxImagePipeline
# 下载模型
snapshot_download(
model_id="MAILAND/majicflus_v1",
allow_file_pattern="majicflus_v134.safetensors",
cache_dir="models"
)
snapshot_download(
model_id="black-forest-labs/FLUX.1-dev",
allow_file_pattern=["ae.safetensors", "text_encoder/model.safetensors", "text_encoder_2/*"],
cache_dir="models"
)
# 加载模型
model_manager = ModelManager(
torch_dtype=torch.bfloat16,
device="cuda",
file_path_list=[
"models/black-forest-labs/FLUX.1-dev/text_encoder/model.safetensors",
"models/black-forest-labs/FLUX.1-dev/text_encoder_2",
"models/black-forest-labs/FLUX.1-dev/ae.safetensors",
"models/MAILAND/majicflus_v1/majicflus_v134.safetensors",
]
)
pipe = FluxImagePipeline.from_model_manager(model_manager, device="cuda")
# 生图!
image = pipe(prompt="a beautiful girl", seed=0)
image.save("image.jpg")
```