build: 添加构建文件.
This commit is contained in:
BIN
dist/cifar100-0.2.0-py3-none-any.whl
vendored
Normal file
BIN
dist/cifar100-0.2.0-py3-none-any.whl
vendored
Normal file
Binary file not shown.
BIN
dist/cifar100-0.2.0.tar.gz
vendored
Normal file
BIN
dist/cifar100-0.2.0.tar.gz
vendored
Normal file
Binary file not shown.
120
src/cifar100.egg-info/PKG-INFO
Normal file
120
src/cifar100.egg-info/PKG-INFO
Normal file
@@ -0,0 +1,120 @@
|
||||
Metadata-Version: 2.4
|
||||
Name: cifar100
|
||||
Version: 0.2.0
|
||||
Summary: Cifar100 classification using PyTorch
|
||||
Requires-Python: >=3.13
|
||||
Description-Content-Type: text/markdown
|
||||
License-File: LICENSE
|
||||
Requires-Dist: matplotlib>=3.10.7
|
||||
Requires-Dist: numpy>=2.3.3
|
||||
Requires-Dist: torch>=2.8.0
|
||||
Requires-Dist: torchvision>=0.23.0
|
||||
Dynamic: license-file
|
||||
|
||||
# CIFAR100 图像分类项目
|
||||
|
||||
## 项目简介
|
||||
这个项目使用PyTorch框架和Wide ResNet模型对CIFAR100数据集进行训练和分类。项目采用标准的src layout结构,代码模块化,便于维护和扩展。
|
||||
|
||||
## 项目结构
|
||||
```
|
||||
Cifar100/
|
||||
├── src/
|
||||
│ └── cifar100/
|
||||
│ ├── __init__.py # 包初始化文件
|
||||
│ ├── data.py # 数据加载和预处理
|
||||
│ ├── model.py # 模型定义(Wide ResNet)
|
||||
│ └── trainer.py # 训练和评估功能
|
||||
├── main.py # 项目入口点
|
||||
├── pyproject.toml # 项目依赖和配置
|
||||
├── README.md # 项目说明文档
|
||||
└── .gitignore # Git忽略规则
|
||||
```
|
||||
|
||||
## 数据集信息
|
||||
- 数据集:CIFAR-100
|
||||
- 图片尺寸:32×32像素
|
||||
- 数据集类别数量:100
|
||||
- 数据量:60000张图片
|
||||
- 数据划分:
|
||||
- 训练数据:50000张(每个类别500张)
|
||||
- 测试数据:10000张(每个类别100张)
|
||||
|
||||
## 模型介绍
|
||||
本项目使用Wide ResNet (WRN) 模型,具体为WRN-34-10配置:
|
||||
- 34代表卷积层个数
|
||||
- 10代表宽度因子(卷积层的宽度)
|
||||
|
||||
模型结构:
|
||||
- 初始卷积层:3×3,16个过滤器
|
||||
- 第1个block组:32×32输出尺寸,包含5个block,每个block有2个3×3卷积层
|
||||
- 第2个block组:16×16输出尺寸,包含5个block,每个block有2个3×3卷积层
|
||||
- 第3个block组:8×8输出尺寸,包含5个block,每个block有2个3×3卷积层
|
||||
- 全局平均池化:8×8→1×1
|
||||
- 全连接层:输出100个类别
|
||||
|
||||
## 数据预处理与增强
|
||||
训练集数据增强包括:
|
||||
- 随机裁剪(32×32,填充4像素)
|
||||
- 随机水平翻转
|
||||
- 转换为Tensor
|
||||
- 归一化处理
|
||||
- Cutout数据增强(随机遮挡部分图像)
|
||||
|
||||
测试集只进行:
|
||||
- 转换为Tensor
|
||||
- 归一化处理
|
||||
|
||||
## 训练参数
|
||||
- 批量大小:128
|
||||
- 训练轮数:200
|
||||
- 初始学习率:0.1
|
||||
- 优化器:SGD(带动量0.9,权重衰减5e-4)
|
||||
- 学习率调度:在第60、120、160轮将学习率乘以0.2
|
||||
- Dropout概率:0.3
|
||||
|
||||
## 运行说明
|
||||
|
||||
### 开发环境安装
|
||||
|
||||
在开发环境中,可以使用开发模式安装项目,包含所有开发工具:
|
||||
|
||||
```bash
|
||||
pip install -e "[dev]"
|
||||
```
|
||||
|
||||
### 生产环境安装
|
||||
|
||||
在生产环境中,可以直接安装构建好的wheel包或从源码安装:
|
||||
|
||||
```bash
|
||||
# 从源码安装基本版本
|
||||
pip install .
|
||||
|
||||
# 或安装预构建的wheel包
|
||||
pip install dist/cifar100-0.2.0-py3-none-any.whl
|
||||
```
|
||||
|
||||
### 运行训练
|
||||
|
||||
确保已安装Python 3.13或更高版本,安装完成后,运行训练脚本:
|
||||
|
||||
```bash
|
||||
python main.py
|
||||
```
|
||||
|
||||
详细的打包和安装指南请参考 [PACKAGING_GUIDE.md](PACKAGING_GUIDE.md) 文件。
|
||||
|
||||
## 模型保存
|
||||
每20个epoch会保存一次模型权重,文件格式为:`wrn34_10_epoch_{epoch}.pth`
|
||||
|
||||
## 注意事项
|
||||
- 首次运行时会自动下载CIFAR100数据集到`./data`目录
|
||||
- 训练过程中会打印每个epoch的训练损失、训练准确率、测试损失和测试准确率
|
||||
- 如需调整参数,请修改`main()`函数中的相应变量
|
||||
|
||||
## 模块说明
|
||||
1. **data.py**: 包含数据加载、预处理和增强的相关功能
|
||||
2. **model.py**: 定义了Block和WideResNet模型结构
|
||||
3. **trainer.py**: 实现了训练、评估和模型保存的功能
|
||||
4. **main.py**: 项目的入口点,整合各个模块并启动训练过程
|
||||
14
src/cifar100.egg-info/SOURCES.txt
Normal file
14
src/cifar100.egg-info/SOURCES.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
LICENSE
|
||||
README.md
|
||||
pyproject.toml
|
||||
src/cifar100/__init__.py
|
||||
src/cifar100/config.py
|
||||
src/cifar100/data.py
|
||||
src/cifar100/model.py
|
||||
src/cifar100/trainer.py
|
||||
src/cifar100/visualizer.py
|
||||
src/cifar100.egg-info/PKG-INFO
|
||||
src/cifar100.egg-info/SOURCES.txt
|
||||
src/cifar100.egg-info/dependency_links.txt
|
||||
src/cifar100.egg-info/requires.txt
|
||||
src/cifar100.egg-info/top_level.txt
|
||||
1
src/cifar100.egg-info/dependency_links.txt
Normal file
1
src/cifar100.egg-info/dependency_links.txt
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
4
src/cifar100.egg-info/requires.txt
Normal file
4
src/cifar100.egg-info/requires.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
matplotlib>=3.10.7
|
||||
numpy>=2.3.3
|
||||
torch>=2.8.0
|
||||
torchvision>=0.23.0
|
||||
1
src/cifar100.egg-info/top_level.txt
Normal file
1
src/cifar100.egg-info/top_level.txt
Normal file
@@ -0,0 +1 @@
|
||||
cifar100
|
||||
Reference in New Issue
Block a user