You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 🎨 AI 画风迁移器 (StyleTransferAI)
一个新颖、轻量级的Python项目旨在通过神经风格迁移算法实现快速有趣的艺术风格转换效果。
## 🚀 快速开始
<<<<<<< HEAD
1. **克隆项目**
```bash
git clone https://github.com/yourname/style_transfer_ai.git
cd style_transfer_ai1
```
=======
1.**项目介绍**
>>>>>>> 626e5f869ec0cab1cc44a7f603dcaedb22fd4cce
2. **创建虚拟环境并安装依赖**
```bash
python -m venv venv
source venv/bin/activate # Linux/Mac
# venv\Scripts\activate # Windows
pip install -r requirements.txt
```
3. **准备图像**
`data/raw/` 目录下放置你的内容图 (`content.jpg`) 和风格图 (`style.jpg`)。
4. **运行程序**
```bash
python scripts/run_style_transfer.py
```
5. **查看结果**
结果将保存在 `data/processed/result_时间戳.jpg`
## 💡 项目特点
- **高质量风格迁移**: 基于VGG16深度学习模型生成高质量艺术效果。
- **速度快**: CPU优化无需GPU即可快速运行。
- **可视化监控**: 实时显示训练损失,生成详细损失曲线图。
- **高度可定制**: 修改 `configs/default.yaml` 或核心代码即可调整风格迁移效果。
- **多模式训练**: 提供快速、扩展、高级三种训练模式。
## 📂 项目结构
```
style_transfer_ai/
├── configs/ # 配置文件目录
│ └── default.yaml # 默认超参数配置(学习率、迭代次数、权重等)
├── data/ # 数据目录
│ ├── raw/ # 原始输入图像
│ │ ├── content.jpg # 内容图像(用户自定义)
│ │ └── style.jpg # 风格图像(用户自定义)
│ └── processed/ # 输出结果目录(自动生成)
│ └── result_20251202_2227.jpg # 示例输出(带时间戳)
├── models/ # 模型相关代码
│ └── vgg16_extractor.py # VGG16特征提取器封装
├── scripts/ # 可执行脚本
│ └── run_style_transfer.py # 主程序入口
├── src/ # 核心源代码
│ ├── style_transfer.py # 风格迁移核心算法实现
│ ├── loss.py # 内容损失、风格损失计算
│ ├── utils.py # 图像预处理、后处理、可视化工具
│ └── trainer.py # 训练循环与优化器管理
├── outputs/ # 日志与可视化输出
│ └── loss_curve_*.png # 损失变化曲线图(按运行时间命名)
├── requirements.txt # Python依赖列表
├── README.md # 项目说明文档(即本文件)
└── .gitignore # Git忽略规则
```