Go to file
TaurusXin 58e344ef13 first commit 2023-12-29 19:53:46 +08:00
data first commit 2023-12-29 19:53:46 +08:00
input first commit 2023-12-29 19:53:46 +08:00
ui first commit 2023-12-29 19:53:46 +08:00
.gitignore first commit 2023-12-29 19:53:46 +08:00
README.md first commit 2023-12-29 19:53:46 +08:00
mnist_net.py first commit 2023-12-29 19:53:46 +08:00
mnist_test.py first commit 2023-12-29 19:53:46 +08:00
mnist_train.py first commit 2023-12-29 19:53:46 +08:00
webui.py first commit 2023-12-29 19:53:46 +08:00

README.md

MNIST 数据集

使用 PyTorch 训练

依赖安装

首先根据 PyTorch 官网 安装 PyTorch以便启用 GPU 加速

然后安装其他依赖

pip install fastapi uvicorn pillow tqdm

训练模型

首先你当然要先训练模型啦

python mnist_train.py --save-model

使用方法

训练完模型后,本仓库包含两种使用方法,即本地文件和 Web UI

本地文件

将图片文件放到 input 文件夹内,必须是 28*28 的灰度png格式然后执行

python mnist.test.py

Web UI

执行以下命令启动 Web UI

uvicorn webui:app

然后打开 http://127.0.0.1:8000 即可看到网页