{"id":18077580,"url":"https://github.com/rentainhe/mini-classification","last_synced_at":"2026-02-03T02:06:58.419Z","repository":{"id":119477280,"uuid":"330102754","full_name":"rentainhe/mini-classification","owner":"rentainhe","description":"lightweight and efficient classification project based on pytorch-lightning","archived":false,"fork":false,"pushed_at":"2021-09-16T09:29:09.000Z","size":471,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T16:46:02.602Z","etag":null,"topics":["attention","classification","ddp-training","efficient","imagenet","lightweight","pytorch","pytorch-lightning","pytorch-models","vision","vision-transformer"],"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/rentainhe.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","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":"2021-01-16T06:49:37.000Z","updated_at":"2025-01-17T12:39:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"0c0e1419-69ff-4aed-8b8a-239085c2e6fb","html_url":"https://github.com/rentainhe/mini-classification","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rentainhe/mini-classification","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rentainhe%2Fmini-classification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rentainhe%2Fmini-classification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rentainhe%2Fmini-classification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rentainhe%2Fmini-classification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rentainhe","download_url":"https://codeload.github.com/rentainhe/mini-classification/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rentainhe%2Fmini-classification/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263282609,"owners_count":23442205,"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":["attention","classification","ddp-training","efficient","imagenet","lightweight","pytorch","pytorch-lightning","pytorch-models","vision","vision-transformer"],"created_at":"2024-10-31T11:45:52.630Z","updated_at":"2026-02-03T02:06:58.386Z","avatar_url":"https://github.com/rentainhe.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mini-Classification\nMini-Classification是一个基于pytorch-lightning写的轻量化的图像分类代码框架\n\n\n### 初衷\n为什么需要基于pytorch-lightning写一个分类任务的框架？\n- **学习目的** 首先pytorch-lightning是基于pytorch代码进一步wrap的一个代码框架，提供了更高级别抽象的API，让我们在使用pytorch的过程中，可以更加专注于模型部分，而不需要去考虑一些额外的代码结构，例如**分布式训练**，**Log的保存**， **resume training**， **半精度训练**等，这些在pytorch-lightning中都可以通过简单的配置实现，并且pytorch-lightning中配置了许多好用的API以及function，这让我出于学习的好奇心，想亲自体验一下pytorch-lightning的方便，并且想把方便带给他人。\n- **任务简单** 分类任务是深度学习中最经典的，也是最好入门，最友好的，并且分类任务的实现并不复杂，可以让我在更新开源项目的同时，更加专注pytorch-lightning框架本身的学习。\n- **适用多样性** 我思考过一个优秀的开源项目应该做到哪些部分来适用不同的人群，如果只是基于pytorch去写一个这样的框架，那其实是一件意义不大的事情，因为优秀的开源项目太多了，但是基于pytorch-lightning项目去写一个开源框架，有以下几个好处：\n  - **面向小白** 对于深度学习入门选手，可以快速上手体验，方便使用者专注于模型的理解，并体验不同的模型实验效果，但是不推荐依赖于pytorch-lightning去写自己之后的代码，因为pytorch本身的使用场景还是更广，并且更有助于你对于代码内部逻辑的理解。\n  - **面向进阶者** 对于进阶者而言，Mini-Classification致力于尽量将使用者研究时需要的内容容纳进来，并且将代码拓展性尽量做好，便于使用。\n- **开源精神** 想做好一个完整的开源项目，如果使用者有更好的想法，非常欢迎对这个小小的开源项目提供支持和帮助。\n\n### 基本功能\n- [x] 配置统一的config文件\n- [x] 实现完整的模型训练流程，并且默认保存模型训练过程中的最好结果\n- [x] 配置tensorboard，记录训练过程中的变量：`training loss`, `learning rate`, `acc1`, `acc5`, `validation loss`等\n- [x] 增加`step`, `cosine`, `linear`三种`lr_scheduler`。\n- [x] 增加`DP`和`DDP`训练功能，并且可以通过`args`来指定特定的`device`\n- [x] 增加`fp16`半精度训练\n\n### 更新日志\n如果需要了解`mini-classification`最新的更新，可以查看[changelog.md](/changelog.md)获取更多细节\n\n## 安装与使用\n### 安装\n安装`pytorch-lightning`, `timm`以及其他相关库\n```bash\n$ pip install pytorch-lightning\n$ pip install timm\n$ pip install -r requirements.txt\n```\n\n### 使用\n#### 1. 训练\n**example**\n\n在cifar100任务上使用指定GPU与DDP训练resnet18模型\n```bash\n$ python run.py --cfg configs/cifar100/resnet/resnet18.yaml --gpu 0,1 --accelerator ddp\n```\n\n## Acknowledgements\n非常感谢以下优秀的开源代码所提供的参考\n- [pytorch-image-models](https://github.com/rwightman/pytorch-image-models)\n- [Swin-Transformer](https://github.com/microsoft/Swin-Transformer)\n- [pytorch-cifar100](https://github.com/weiaicunzai/pytorch-cifar100)\n- [deit](https://github.com/facebookresearch/deit)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frentainhe%2Fmini-classification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frentainhe%2Fmini-classification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frentainhe%2Fmini-classification/lists"}