TorchCFM 项目使用教程
1. 项目目录结构及介绍
TorchCFM 项目的目录结构如下:
conditional-flow-matching/
├── assets/
├── examples/
│ ├── models/
│ └── notebooks/
├── runner/
├── tests/
├── torchcfm/
├── .gitignore
├── pre-commit-config.yaml
├── LICENSE
├── README.md
├── pyproject.toml
├── requirements.txt
├── runner-requirements.txt
└── setup.py
目录介绍:
- assets/: 存放项目相关的资源文件。
- examples/: 包含项目的示例代码和 Jupyter 笔记本。
- models/: 存放示例中使用的模型文件。
- notebooks/: 存放 Jupyter 笔记本示例。
- runner/: 包含项目的运行脚本和实验代码。
- tests/: 存放项目的测试代码。
- torchcfm/: 项目的核心代码包。
- .gitignore: Git 忽略文件配置。
- pre-commit-config.yaml: 预提交钩子配置文件。
- LICENSE: 项目许可证文件。
- README.md: 项目说明文档。
- pyproject.toml: 项目配置文件。
- requirements.txt: 项目依赖文件。
- runner-requirements.txt: 运行脚本的依赖文件。
- setup.py: 项目安装脚本。
2. 项目启动文件介绍
项目的启动文件主要位于 runner/
目录下。以下是一些关键的启动文件:
- runner/main.py: 这是项目的主启动文件,包含了主要的运行逻辑和实验设置。
- runner/train.py: 用于训练模型的脚本。
- runner/evaluate.py: 用于评估模型的脚本。
启动步骤:
-
克隆项目到本地:
git clone https://github.com/atong01/conditional-flow-matching.git cd conditional-flow-matching
-
安装依赖:
pip install -r requirements.txt pip install -e .
-
运行主启动文件:
python runner/main.py
3. 项目的配置文件介绍
项目的配置文件主要位于根目录下,以下是一些关键的配置文件:
- pyproject.toml: 项目的主要配置文件,包含了项目的元数据、依赖和构建配置。
- requirements.txt: 项目依赖文件,列出了项目运行所需的所有 Python 包。
- runner-requirements.txt: 运行脚本的依赖文件,列出了运行脚本所需的所有 Python 包。
- setup.py: 项目安装脚本,用于打包和安装项目。
配置文件示例:
pyproject.toml:
[project]
name = "conditional-flow-matching"
version = "0.1.0"
description = "TorchCFM: a Conditional Flow Matching library"
authors = [
{ name="Alexander Tong", email="atong@cs.toronto.edu" },
]
dependencies = [
"torch>=1.10.0",
"numpy>=1.21.0",
"matplotlib>=3.4.0",
]
requirements.txt:
torch>=1.10.0
numpy>=1.21.0
matplotlib>=3.4.0
通过这些配置文件,可以轻松管理项目的依赖和构建过程。