{"id":18553006,"url":"https://github.com/lunarwhite/yolo-student-counter","last_synced_at":"2025-04-09T22:32:11.972Z","repository":{"id":46078605,"uuid":"377002910","full_name":"lunarwhite/yolo-student-counter","owner":"lunarwhite","description":"Monitor in classroom headcount, support image/video/live streaming as input. 教室人数检测统计","archived":false,"fork":false,"pushed_at":"2025-03-22T03:33:11.000Z","size":3337,"stargazers_count":39,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T04:24:16.006Z","etag":null,"topics":["deep-learning","object-detection","python","pytorch","yolov5"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lunarwhite.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2021-06-15T01:37:08.000Z","updated_at":"2025-03-22T03:33:08.000Z","dependencies_parsed_at":"2023-12-13T11:42:11.901Z","dependency_job_id":"9cb833f0-be58-4889-b98b-0a7bc191452b","html_url":"https://github.com/lunarwhite/yolo-student-counter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunarwhite%2Fyolo-student-counter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunarwhite%2Fyolo-student-counter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunarwhite%2Fyolo-student-counter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunarwhite%2Fyolo-student-counter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lunarwhite","download_url":"https://codeload.github.com/lunarwhite/yolo-student-counter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248123814,"owners_count":21051537,"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":["deep-learning","object-detection","python","pytorch","yolov5"],"created_at":"2024-11-06T21:15:49.125Z","updated_at":"2025-04-09T22:32:08.800Z","avatar_url":"https://github.com/lunarwhite.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yolo-student-counter\n\n![GitHub Repo stars](https://img.shields.io/github/stars/lunarwhite/yolo-student-counter?color=orange)\n![GitHub watchers](https://img.shields.io/github/watchers/lunarwhite/yolo-student-counter?color=yellow)\n![GitHub forks](https://img.shields.io/github/forks/lunarwhite/yolo-student-counter?color=green)\n![GitHub top language](https://img.shields.io/github/languages/top/lunarwhite/yolo-student-counter)\n![GitHub License](https://img.shields.io/github/license/lunarwhite/yolo-student-counter?color=white)\n\nMonitor in classroom headcount, support image/video/live streaming as input. 基于YOLOv5的教室人数检测统计，支持图片、视频和直播流等多种媒体输入格式\n\n```\n.\n├── dataset # 数据集\n│   ├── annotations # XML 标签\n│   ├── images # 图片\n│   └── labels # txt 标签\n├── detect.sh # detect shell 脚本\n├── hellodata.py # 数据探索、预处理\n├── LICENSE\n├── README.md\n├── res\n│   ├── demo_picture1.png # 样例图片\n│   └── demo_picture2.png\n├── runs\n│   ├── detect # 训练后的文件结果\n│   └── train # 训练后的权重\n├── train.sh # train shell 脚本\n├── xml2txt.py # 将 XML 转换为 txt 标签\n└── yolov5 # 从 @ultralytics/yolov5 clone\n    ├── data\n    │   ├── coco.yaml\n    │   ├── headset.yaml # 自定义训练集\n    │   ├── hyp.scratch.yaml\n    │   ├── images # 存放 detect 输入数据\n    │   │   ├── bus.jpg\n    │   │   └── zidane.jpg\n    │   └── videos # 存放 detect 输入数据\n    ├── detect.py\n    ├── Dockerfile\n    ├── hubconf.py\n    ├── models # 预训练模型 YAML 文件\n    ├── requirements.txt # Python 依赖库\n    ├── test.py\n    ├── train.py\n    ├── utils\n    └── weights # 预训练权重\n```\n\n## 1 Overview\n\n- 目标检测 (Object Detection) 在教室人数统计上的应用尝试\n- 先借助 [YOLOv5](https://github.com/ultralytics/yolov5) 预训练模型对图片数据集进行训练，再测试多种输入流\n- 数据集下载：[Classroom Monitoring Dataset - kaggle](https://www.kaggle.com/lunarwhite/classroom-monitoring-dataset)\n  - images 图片\n    - partA 2000张，格式： `[PartA_num].jpg`\n    - partB 2405张，格式：`[PartB_num].jpg`\n  - annotations 标签，标注了图片中 目标的类别和坐标位置\n    - partA 2000条，格式：`[PartA_num].xml`\n    - partB 2405条，格式：`[PartB_num].xml`\n- 主要工具包版本为 PyTorch `1.7.1+cu110` 和 Python `3.8.5`\n\n## 2 Setup\n\n- clone repo：`git clone https://github.com/lunarwhite/yolo-student-counter.git`\n- 更新 pip：`pip3 install --upgrade pip`\n- 为项目创建虚拟环境：`conda create --name \u003cenv_name\u003e python=3.8`\n- 激活 env：`conda activate \u003cenv_name\u003e`\n- 安装 Python 库依赖：`pip3 install -r yolov5/requirements.txt`\n- [下载](https://github.com/ultralytics/yolov5/releases)预训练权重，把下载的 `.pt` 文件部署在 `yolov5/weights/` 路径下\n\n## 3 Train\n\n- 为了方便执行，编写了脚本 [detect.sh](./detect.sh) 和 [train.sh](./train.sh)，分别进行训练与预测测试\n- 根据训练效果调整 `train.sh` 文件中常用参数：\n  ```python\n  --epochs # 训练的 epoch，默认值 300\n  --batch-size # 默认值 16\n  --cfg yolov5s.yaml --weights '' # 从头开始训练\n  --cfg yolov5s.yaml --weights yolov5s.pt # 从预训练模型开始训练\n  --data # 数据集的配置文件，默认为 data/coco128.yaml\n  --resume # 是否从最新的 last.pt 中恢复训练，布尔值\n  --evolve # 进化超参数 (Evolve Hyperparameters)，布尔值\n  --cache-images # 缓存图片可以更快的开始训练，布尔值\n  --weights # 初始化参数路径，默认值 ''\n  --adam # 使用 adam 优化器，布尔值\n  ```\n- 一般只需改动这两个脚本文件就可，如需训练自定义的数据集，请参考官方文档：[Train Custom Data - YOLOv5 Documentation](https://docs.ultralytics.com/yolov5/tutorials/train_custom_data/)\n\n## 4 Workflow\n\n- 自定义数据集\n- 观察数据\n  - 数据集大小\n  - 数据集样本\n  - 图像分辨率  \n- 数据预处理\n  - 数据清洗，观察发现，有一些图像的 label 存在缺失，在 `XML` 转换 `TXT` 的过程中一并丢弃\n  - YOLOv5 原生预处理\n- 搭建模型，可视化分析\n  - 分析与调整训练，提高模型泛化能力\n  - demo 的 detect 结果：\n    ![demo_picture1.png](./res/demo_picture1.png)\n    ![demo_picture2.png](./res/demo_picture2.png)\n- 改进模型\n  - 可视化图形界面 [TODO]\n  - 优化目录结构，提高封装性 [TODO]\n\n## 5 Reference\n\n- [Getting Started - YOLOv5 Documentation](https://docs.ultralytics.com/yolov5/quickstart_tutorial/)\n- [Train Custom Data - YOLOv5 Documentation](https://docs.ultralytics.com/yolov5/tutorials/train_custom_data/)\n- [Tips for Best Training Results - YOLOv5 Documentation]( https://github.com/ultralytics/yolov5/wiki/Tips-for-Best-Training-Results)\n- [Transfer Learning with Frozen Layers - YOLOv5 Documentation](https://github.com/ultralytics/yolov5/issues/1314)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flunarwhite%2Fyolo-student-counter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flunarwhite%2Fyolo-student-counter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flunarwhite%2Fyolo-student-counter/lists"}