---
title: Qwen-Image-Edit-F2P
canonical_url: "https://www.modelscope.cn/models/DiffSynth-Studio/Qwen-Image-Edit-F2P"
md_url: "https://www.modelscope.cn/models/DiffSynth-Studio/Qwen-Image-Edit-F2P.md"
repository: DiffSynth-Studio/Qwen-Image-Edit-F2P
chinese_name: "Qwen-Image-Edit-F2P 人脸生成图像"
last_updated: 2025-10-17
license: "Apache License 2.0"
pipeline_tag: text-to-image-synthesis
tasks:
  - text-to-image-synthesis
base_model:
  - Qwen/Qwen-Image-Edit
base_model_relation: adapter
parameters: 235.9M
tensor_type:
  - BF16
library_name:
  - pytorch
  - lora
  - safetensors
frameworks:
  - Pytorch
supports_inference: img2img
downloads: 15486
stars: 173
tags:
  - LoRA
---

# Qwen-Image-Edit-F2P

> Qwen-Image-Edit-F2P - DiffSynth-Studio 在 ModelScope 开源的模型。Qwen-Image-Edit 人脸生成图像模型

DiffSynth-Studio/Qwen-Image-Edit-F2P 是 ModelScope 魔搭社区上的 235.9M 参数text-to-image-synthesis模型，采用 Apache License 2.0 许可，基于 Qwen/Qwen-Image-Edit 构建，并支持在线推理（img2img）。

- **Repository**: DiffSynth-Studio/Qwen-Image-Edit-F2P
- **License**: Apache License 2.0
- **Tasks**: text-to-image-synthesis
- **Parameters**: 235.9M
- **Base model**: Qwen/Qwen-Image-Edit
- **Online inference**: img2img
- **Tags**: LoRA
- **Downloads**: 15486
- **Stars**: 173
- **Last updated**: 2025-10-17

Source: https://www.modelscope.cn/models/DiffSynth-Studio/Qwen-Image-Edit-F2P

---

# Qwen-Image-Edit 人脸生成图像模型

## 模型介绍

本模型是基于 [Qwen-Image-Edit](https://modelscope.cn/models/Qwen/Qwen-Image-Edit) 训练的人脸控制图像生成模型，可直接根据人脸图像生成漂亮的全身照片。

**请注意，本模型的输入图像为裁剪后的人脸图像，请不要在输入图像中保留除人脸外的其他区域和内容。**

* 训练数据：由[麦橘](https://modelscope.cn/profile/merjic)提供
* 模型结构：LoRA
* 基础模型：[Qwen-Image-Edit](https://modelscope.cn/models/Qwen/Qwen-Image-Edit)
* 训练代码：[DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio/blob/main/examples/qwen_image/model_training/lora/Qwen-Image-Edit.sh)

## 效果展示

提示词：摄影。一个年轻女性穿着黄色连衣裙，站在花田中，背景是五颜六色的花朵和绿色的草地。

|输入图|生成图1|生成图2|生成图3|
|-|-|-|-|
|![](./assets/example_0/face_image.png)|![](./assets/example_0/image_0_0.jpg)|![](./assets/example_0/image_0_1.jpg)|![](./assets/example_0/image_0_2.jpg)|

提示词：摄影。一位年轻漂亮的女子身着淡绿色和白色相间的古装，衣带飘飘，手执长剑，立于古风长廊，光影斑驳，典雅婉约。

|输入图|生成图1|生成图2|生成图3|
|-|-|-|-|
|![](./assets/example_0/face_image.png)|![](./assets/example_0/image_1_0.jpg)|![](./assets/example_0/image_1_1.jpg)|![](./assets/example_0/image_1_2.jpg)|

提示词：一位年轻女子身穿黑色皮夹克和蓝色牛仔裤，站在红砖墙与金属结构的工业风建筑中，阳光洒落，神情自然。

|输入图|生成图1|生成图2|生成图3|
|-|-|-|-|
|![](./assets/example_0/face_image.png)|![](./assets/example_0/image_2_0.jpg)|![](./assets/example_0/image_2_1.jpg)|![](./assets/example_0/image_2_2.jpg)|

提示词：一位年轻女子身穿高雅的红色礼服，手上拿着一本书，脖子上戴着银色项链，她的神情典雅端庄，背景是巴黎凯旋门

|输入图|生成图1|生成图2|生成图3|
|-|-|-|-|
|![](./assets/example_0/face_image.png)|![](./assets/example_0/image_3_0.jpg)|![](./assets/example_0/image_3_1.jpg)|![](./assets/example_0/image_3_2.jpg)|

## 推理代码

安装 [DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio)：

```shell
git clone https://github.com/modelscope/DiffSynth-Studio.git  
cd DiffSynth-Studio
pip install -e .
```

推理代码：

```python
from diffsynth.pipelines.qwen_image import QwenImagePipeline, ModelConfig
import torch
from PIL import Image

pipe = QwenImagePipeline.from_pretrained(
    torch_dtype=torch.bfloat16,
    device="cuda",
    model_configs=[
        ModelConfig(model_id="Qwen/Qwen-Image-Edit", 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", origin_file_pattern="vae/diffusion_pytorch_model.safetensors"),
    ],
    tokenizer_config=None,
    processor_config=ModelConfig(model_id="Qwen/Qwen-Image-Edit", origin_file_pattern="processor/"),
)
pipe.load_lora(pipe.dit, lora_config=ModelConfig(model_id="DiffSynth-Studio/Qwen-Image-Edit-F2P", origin_file_pattern="model.safetensors"))

face_image = Image.open("face_image.png").convert("RGB")
image = pipe(
    prompt="摄影。一个年轻女性穿着黄色连衣裙，站在花田中，背景是五颜六色的花朵和绿色的草地。",
    negative_prompt="将人物的手指改为残缺的、扭曲的，放大头部使其头身比异常，把人物变成身材矮小的大头娃娃，生成刺眼的阳光，让整个画面色彩变得过饱和，把双腿扭曲成X型腿或O型腿",
    edit_image=face_image,
    seed=0,
    num_inference_steps=40,
    height=1152, width=864,
)
image.save("image.jpg")
```

此外，我们还提供了以下代码，以便从人像照片中裁剪出人脸部分，作为本模型的输入：

```python
from modelscope import snapshot_download
from insightface.app import FaceAnalysis
from PIL import Image
import numpy as np
import cv2

def initialize_face_detector():
    snapshot_download("ByteDance/InfiniteYou", allow_file_pattern="supports/insightface/*", cache_dir="models")
    face_detector = FaceAnalysis(name='antelopev2', root="models/ByteDance/InfiniteYou/supports/insightface")
    face_detector.prepare(ctx_id=0, det_size=(640, 640))
    return face_detector

def crop_face(face_detector, image):
    face_info = face_detector.get(cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR))
    bbox = sorted(face_info, key=lambda x: (x['bbox'][2] - x['bbox'][0]) * (x['bbox'][3] - x['bbox'][1]))[-1]['bbox']
    face_image = image.crop(list(map(int, bbox)))
    return face_image

face_detector = initialize_face_detector()
image = Image.open("photo.jpg")
crop_face(face_detector, image).save("face.jpg")
```
