{"id":21503575,"url":"https://github.com/liu42/flowerclassify","last_synced_at":"2025-07-15T23:31:39.278Z","repository":{"id":213291643,"uuid":"727119150","full_name":"LIU42/FlowerClassify","owner":"LIU42","description":"基于 ResNet 的花卉分类识别系统。","archived":false,"fork":false,"pushed_at":"2025-06-20T09:37:20.000Z","size":9,"stargazers_count":28,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-20T10:42:47.083Z","etag":null,"topics":["cnn","computer-vision","deep-learning","docker","flask","image-classification","machine-learning","onnx","onnx-runtime","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LIU42.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-04T08:16:47.000Z","updated_at":"2025-06-20T09:37:23.000Z","dependencies_parsed_at":"2023-12-19T16:09:06.914Z","dependency_job_id":"0785b887-a741-4e8d-a532-740e6ee8b555","html_url":"https://github.com/LIU42/FlowerClassify","commit_stats":null,"previous_names":["liu42/flowerclassify"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/LIU42/FlowerClassify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIU42%2FFlowerClassify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIU42%2FFlowerClassify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIU42%2FFlowerClassify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIU42%2FFlowerClassify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LIU42","download_url":"https://codeload.github.com/LIU42/FlowerClassify/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIU42%2FFlowerClassify/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265467486,"owners_count":23770733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cnn","computer-vision","deep-learning","docker","flask","image-classification","machine-learning","onnx","onnx-runtime","pytorch"],"created_at":"2024-11-23T18:24:14.464Z","updated_at":"2025-07-15T23:31:39.268Z","avatar_url":"https://github.com/LIU42.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flower Classify\n\n*\u003cu\u003ev1.4.0 新变化：调整数据增强重新训练模型。\u003c/u\u003e*\n\n## 项目简介\n\n本项目为一个基于 ResNet 的花卉分类识别系统，能有效区分 10 中不同类别的花卉，采用 ResNet18 作为主干网络，包含模型的训练、测试以及线上部署（提供容器化部署）。\n\n- 基于 [PyTorch](https://pytorch.org/) 框架进行模型的训练及测试。\n\n- 模型采用 [ONNX](https://onnx.org.cn/onnx/index.html) 格式部署，采用 [ONNX Runtime](https://onnxruntime.ai/) 进行推理。\n\n- 基于 [Flask](https://flask.palletsprojects.com/en/stable/) 框架实现 Web 接口。\n\n- 使用 [Docker](https://www.docker.com/) 进行容器化部署。\n\n训练数据集来自 [Kaggle](https://www.kaggle.com/)，融合了多个数据集并进行了数据清洗，基于预训练模型进行训练。\n\n## 使用说明\n\n### 安装环境依赖\n\n首先使用 pip 安装本项目相关的依赖包：\n\n```shell-session\npip install -r requirements.txt\n```\n\n### 启动 Web 服务\n\n本项目 Web 服务的默认配置文件为 servers/configs/config.toml，其中各个字段描述如下。\n\n| 字段名        | 字段描述                                      |\n|:----------:|:-----------------------------------------:|\n| precision  | 模型推理精度，取值为 \"fp32\" (单精度) 和 \"fp16\" (半精度) 。  |\n| providers  | 模型推理 ONNX Runtime Execution Providers 列表。 |\n| model-path | 模型加载路径。                                   |\n\n从本项目 Release 中下载 [ONNX](https://onnx.org.cn/onnx/index.html) 格式的模型权重文件放入 servers/models 目录后，执行以下命令启动 Web 服务：\n\n```shell-session\nflask --app servers.server run --host=\"0.0.0.0\" --port=9500\n```\n\n### 模型训练\n\n若要使用自己的数据集训练模型，准备好数据集、调整好模型输出格式后，运行 train.py 即可开始训练，训练和验证默认的配置文件为 configs/config.toml，其中各个字段的描述如下。\n\n| 字段名                  | 字段描述                                                                                    |\n|:--------------------:|:---------------------------------------------------------------------------------------:|\n| device               | 设备名称，与 PyTorch 的设备名称保持一致。                                                               |\n| num-epochs           | 训练迭代次数。                                                                                 |\n| num-workers          | 训练及评估数据加载进程数。                                                                           |\n| batch-size           | 训练数据批大小。                                                                                |\n| learning-rate        | 模型训练学习率。                                                                                |\n| weight-decay         | 模型训练权重衰减。                                                                               |\n| num-classes          | 模型输出类别数。                                                                                |\n| log-interval         | 日志输出频率。                                                     |\n| load-pretrained      | 是否使用预训练参数初始化模型权重。                                                                       |\n| load-checkpoint      | 是否加载 checkpoint 继续训练，若为 true 则从 load-path 加载模型权重，覆盖 load-pretrained 值，反之则使用初始化模型权重开始训练。 |\n| load-checkpoint-path | 训练初始模型的加载路径，同时也为待评估模型加载路径。                                                              |\n| best-checkpoint-path | 训练中当前验证集最优模型保存路径。                                                                       |\n| last-checkpoint-path | 训练中最后一次训练模型保存路径。                                                                        |\n\n### 模型评估\n\n模型训练完成后，运行 eval.py 以评估当前最优模型在测试集上的准确率，默认的配置文件及字段含义同上。\n\n### 构建镜像\n\n模型部署前需要转换为 [ONNX](https://onnx.org.cn/onnx/index.html) 格式放入 servers/models 目录中。构建镜像使用的 Dockerfile 位于 docker 目录中，请参考 [Docker 官方文档](https://docs.docker.com/) 进行镜像的构建和容器的运行。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliu42%2Fflowerclassify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliu42%2Fflowerclassify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliu42%2Fflowerclassify/lists"}