---
title: xihu-imageedit
canonical_url: "https://www.modelscope.cn/studios/xihuyisheng/xihu-imageedit"
md_url: "https://www.modelscope.cn/studios/xihuyisheng/xihu-imageedit.md"
repository: xihuyisheng/xihu-imageedit
chinese_name: "换个装"
last_updated: 2026-10-12
sdk_type: gradio
sdk_version: 6.8.0
downloads: 0
stars: 4
---

# xihu-imageedit

> xihu-imageedit - xihuyisheng 在 ModelScope 创建的在线 Demo。基于Gradio和Qwen-Image-Edit API构建的换装功能

xihuyisheng/xihu-imageedit 是 ModelScope 魔搭社区上的在线可交互 Demo（创空间），基于 gradio 6.8.0 构建，中文名为「换个装」。

- **Repository**: xihuyisheng/xihu-imageedit
- **SDK**: gradio
- **SDK version**: 6.8.0
- **Downloads**: 0
- **Stars**: 4
- **Last updated**: 2026-10-12

Source: https://www.modelscope.cn/studios/xihuyisheng/xihu-imageedit

---

# 图像编辑器 (Image Editor)

基于 ModelScope 平台的 Qwen/Qwen-Image-Edit 模型构建的图像编辑 Web 应用。

## 项目简介

本项目是一个基于 Gradio 构建的 Web 应用程序，允许用户通过URL加载图像并使用自然语言指令对其进行编辑。应用通过调用 ModelScope 平台的 Qwen/Qwen-Image-Edit 模型来实现图像编辑功能。

## 功能特性

- 图像URL加载：支持通过URL加载图像文件
- 自然语言编辑：通过文本提示描述想要的图像编辑效果
- 实时预览：即时显示编辑后的图像结果
- API 集成：通过 ModelScope API 调用 Qwen/Qwen-Image-Edit 模型

## 技术栈

- [Gradio](https://gradio.app/): 用于构建 Web 界面
- [ModelScope API](https://modelscope.cn/): 提供 Qwen/Qwen-Image-Edit 模型服务
- [Python](https://www.python.org/): 后端编程语言
- [Pillow](https://python-pillow.org/): 图像处理库
- [Requests](https://docs.python-requests.org/): HTTP 请求库

## 安装与运行

### 环境要求

- Python 3.7 或更高版本
- ModelScope API Key

### 安装步骤

1. 克隆项目代码：
```bash
git clone https://www.modelscope.cn/studios/xihuyisheng/xihu-imageedit.git
cd xihu-imageedit
```

2. 安装依赖：
```bash
pip install -r requirements.txt
```

3. 配置 API Key：
   在项目根目录创建 .env 文件，配置您的 API Key：
   ```env
   myKEY=your_api_key_here
   ```

4. 运行应用：
```bash
python app.py
```

5. 在浏览器中访问 `http://localhost:7860` 查看应用

### 获取 API Key

1. 访问 [ModelScope 官网](https://modelscope.cn/)
2. 注册/登录账号
3. 在控制台，密钥管理页面，创建API-KEY
4. 将 API Key 配置到 .env 文件中

## 使用说明

1. 在 "图像URL" 输入框中输入图片的URL地址，或使用默认的示例图片URL
2. 在 "编辑提示" 文本框中输入您想要的编辑效果描述，例如：
   - "将图中人物的衣服换成红色"
   - "给图片添加下雨的背景"
   - "把图片中的汽车变成飞机"
3. 当URL改变时，图像会自动加载并显示在"编辑前的图像"区域
4. 点击 "编辑图像" 按钮
5. 等待处理完成后，在 "编辑后的图像" 区域查看结果

## 项目结构

```
xihu-imageedit/
├── app.py              # 主应用程序文件
├── .env                # API Key 配置文件（不入库）
├── README.md           # 项目说明文档
└── requirements.txt    # 依赖包列表
```

## API 调用说明

本项目通过 HTTP 请求调用 ModelScope 的图像编辑 API：

- **Endpoint**: `https://api-inference.modelscope.cn/v1/images/generations`
- **Method**: POST
- **Headers**:
  - `Content-Type: application/json`
  - `Authorization: Bearer YOUR_API_KEY`
- **Model**: `Qwen/Qwen-Image-Edit`

## 故障排除

### 常见问题

1. **API 调用失败**
   - 检查网络连接是否正常
   - 确认 API Key 是否正确且有效
   - 检查防火墙或代理设置

2. **图像加载失败**
   - 确保图像URL可访问
   - 检查图像URL是否正确
   - 确保图像格式为 PNG、JPG 等支持的格式

3. **应用无法启动**
   - 确认所有依赖包已正确安装
   - 检查端口是否被其他应用占用

### 支持与反馈

如有问题或建议，请通过以下方式联系我们：
- 交流反馈栏下 提交 Issue 到本项目仓库

## 许可证

本项目采用 Apache License 2.0 许可证。详情请见 [LICENSE](LICENSE) 文件。
