{"id":21029594,"url":"https://github.com/aiboy996/voc-mmdetection","last_synced_at":"2026-04-25T15:35:33.305Z","repository":{"id":242087335,"uuid":"808577096","full_name":"AIboy996/voc-mmdetection","owner":"AIboy996","description":"神经网络和深度学习（DATA620004）期中作业，任务2","archived":false,"fork":false,"pushed_at":"2024-05-31T17:01:29.000Z","size":5088,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-31T01:59:08.390Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AIboy996.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":"2024-05-31T11:03:42.000Z","updated_at":"2024-05-31T17:01:32.000Z","dependencies_parsed_at":"2024-11-19T12:14:37.865Z","dependency_job_id":"cb99bafd-2463-4807-8054-0f32a926257c","html_url":"https://github.com/AIboy996/voc-mmdetection","commit_stats":null,"previous_names":["aiboy996/voc-mmdetection"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AIboy996/voc-mmdetection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AIboy996%2Fvoc-mmdetection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AIboy996%2Fvoc-mmdetection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AIboy996%2Fvoc-mmdetection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AIboy996%2Fvoc-mmdetection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AIboy996","download_url":"https://codeload.github.com/AIboy996/voc-mmdetection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AIboy996%2Fvoc-mmdetection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32267710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T09:15:33.318Z","status":"ssl_error","status_checked_at":"2026-04-25T09:15:31.997Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-19T12:13:18.709Z","updated_at":"2026-04-25T15:35:33.273Z","avatar_url":"https://github.com/AIboy996.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VOC mmdetection\n\n神经网络和深度学习（DATA620004）期中作业，任务2.\n\n## 要求\n在VOC数据集上训练并测试目标检测模型**Faster R-CNN**和**YOLO V3**\n\n- 学习使用现成的目标检测框架——如mmdetection或detectron2——在VOC数据集上训练并测试目标检测模型Faster R-CNN和YOLO V3；\n- 挑选4张测试集中的图像，通过可视化对比训练好的Faster R-CNN第一阶段产生的proposal box和最终的预测结果。\n- 搜集三张不在VOC数据集内包含有VOC中类别物体的图像，分别可视化并比较两个在VOC数据集上训练好的模型在这三张图片上的检测结果（展示bounding box、类别标签和得分）；\n\n## 环境搭建\n我们将使用`mmdetection`来完成这个任务。\n\n首先需要安装`pytorch`，由于`mmdetection`的兼容性，需要安装`cuda 11.7`版本对应的`torch 2.0.1`：\n\n```bash\npip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117\n```\n\u003e FYI，在Windows上可以同时安装多个版本的cuda，只要指定环境变量`CUDA_PATH`即可修改默认的cuda。\n\n\n然后我们安装`openmim`，用它来安装`mmdetection`：\n```bash\npip3 install -U openmim\nmim install mmengine\nmim install \"mmcv==2.1.0\"\nmim install mmdet\n```\n\n## 数据集\n我们使用的是VOC2012数据集。\n\u003e VOC2012这个挑战的目标是从现实场景中的许多视觉对象类别中识别对象（即不是预先分割的对象）。它基本上是一个监督学习问题，因为它提供了一组标记图像的训练集。已选择的 20 个对象类别是： 人：人 动物：鸟、猫、牛、狗、马、羊 交通工具：飞机、自行车、船、公共汽车、汽车、摩托车、火车 室内：瓶子、椅子、餐桌、盆栽、沙发、电视/显示器 将有两个主要比赛和两个较小规模的“品尝者”比赛。内容：提供的训练数据由一组图像组成；每个图像都有一个注释文件，为图像中存在的 20 个类别之一中的每个对象提供一个边界框和对象类别标签。请注意，来自多个类的多个对象可能出现在同一图像中。\n\n### 下载\n```bash\npython tools/misc/download_dataset.py --dataset-name voc2012\n```\n\n### 组织\n数据下载完之后，解压到data文件夹得到如下的结构：\n```\ndata\n└─coco\n    └─VOCtrainval_11-May-2012\n        └─VOCdevkit\n            └─VOC2012\n                ├─Annotations\n                ├─ImageSets\n                │  ├─Action\n                │  ├─Layout\n                │  ├─Main\n                │  └─Segmentation\n                ├─JPEGImages\n                ├─SegmentationClass\n                └─SegmentationObject\n```\n该数据集共计17125个图像。\n### 划分\n我们使用：\n```\ndata/coco/VOCtrainval_11-May-2012/VOCdevkit/VOC2012/ImageSets/Main/train.txt\n```\n（共计5717个图像）作为训练集。\n\n使用：\n```\ndata/coco/VOCtrainval_11-May-2012/VOCdevkit/VOC2012/ImageSets/Main/val.txt\n```\n（共计5717个图像）作为测试集。\n## 模型训练\n使用mmdetection提供的脚本：\n### Faster R-CNN\n\n正常训练：\n```bash\npython tools/train.py configs/faster_rcnn/faster-rcnn_r50_fpn_1x_voc.py\n```\n\n从断点继续训练：\n```bash\npython tools/train.py configs/faster_rcnn/faster-rcnn_r50_fpn_1x_voc.py --resume [checkpoint.pth]\n```\n\n### YOLO V3\n正常训练：\n```bash\npython tools/train.py configs/yolo/yolov3_d53_8xb8-ms-608-273e_voc_base.py\n```\n\n从断点继续训练：\n```bash\npython tools/train.py configs/yolo/yolov3_d53_8xb8-ms-608-273e_voc_base.py --resume [checkpoint.pth]\n```\n\n训练完的日志和权重保存在work_dirs文件夹。\n\n## 模型测试\n使用mmdetection提供的脚本：\n### Faster R-CNN\n```bash\npython tools/test.py configs/faster_rcnn/faster-rcnn_r50_fpn_1x_voc.py work_dirs/faster-rcnn_r50_fpn_1x_voc/epoch_10.pth\n```\n### YOLO V3\n```bash\npython tools/test.py configs/yolo/yolov3_d53_8xb8-ms-608-273e_voc_base.py work_dirs/yolov3_d53_8xb8-ms-608-273e_voc_base/epoch_100.pth\n```\n\n## 模型推理\n\n```bash\npython inference.py\n```\n一例：\n\n- 原图：\n    - ![alt text](demo/in/2009_000759.jpg)\n- 可视化bounding box：\n    - ![alt text](outputs/in/vis/2009_000759.jpg)\n- 模型输出：\n```json\n{\n    \"labels\": [\n        14,\n        14,\n        14,\n        14,\n        14,\n        4,\n        10,\n        14,\n        14,\n        14,\n        14,\n        10,\n        10,\n        14,\n        14,\n        14,\n        14\n    ],\n    \"scores\": [\n        0.999847412109375,\n        0.9996101260185242,\n        0.9994789958000183,\n        0.9994264841079712,\n        0.9992637038230896,\n        0.9985488057136536,\n        0.9970762729644775,\n        0.9967821836471558,\n        0.9861702919006348,\n        0.9489360451698303,\n        0.4332524836063385,\n        0.22431445121765137,\n        0.17479072511196136,\n        0.16827289760112762,\n        0.13223162293434143,\n        0.11941542476415634,\n        0.059175413101911545\n    ],\n    \"bboxes\": [\n        [\n            91.67660522460938,\n            50.48377990722656,\n            209.81333923339844,\n            228.71080017089844\n        ],\n        [\n            276.7741394042969,\n            81.86434936523438,\n            350.6646423339844,\n            185.0067596435547\n        ],\n        [\n            1.5342577695846558,\n            29.54728126525879,\n            118.23262023925781,\n            253.7919464111328\n        ],\n        [\n            181.2398681640625,\n            56.38529586791992,\n            297.0572204589844,\n            193.12933349609375\n        ],\n        [\n            351.87835693359375,\n            109.37857055664062,\n            399.53753662109375,\n            163.8385467529297\n        ],\n        [\n            172.13270568847656,\n            134.6718292236328,\n            214.30738830566406,\n            203.38827514648438\n        ],\n        [\n            0.3956954777240753,\n            178.3833770751953,\n            461.24554443359375,\n            333.0\n        ],\n        [\n            360.0343322753906,\n            86.17256164550781,\n            496.6365051269531,\n            326.0494079589844\n        ],\n        [\n            396.4289245605469,\n            76.16590881347656,\n            495.6755065917969,\n            215.24337768554688\n        ],\n        [\n            397.35540771484375,\n            87.5771713256836,\n            452.4204406738281,\n            194.97833251953125\n        ],\n        [\n            229.8292694091797,\n            61.49006271362305,\n            285.28558349609375,\n            186.58828735351562\n        ],\n        [\n            230.75759887695312,\n            186.09835815429688,\n            412.2704772949219,\n            333.0\n        ],\n        [\n            0.0,\n            218.197998046875,\n            277.2224426269531,\n            333.0\n        ],\n        [\n            73.6247329711914,\n            61.248268127441406,\n            306.6939392089844,\n            203.2276153564453\n        ],\n        [\n            142.47677612304688,\n            56.185577392578125,\n            259.0111999511719,\n            208.97982788085938\n        ],\n        [\n            49.905826568603516,\n            37.84497833251953,\n            169.13919067382812,\n            247.78897094726562\n        ],\n        [\n            353.74969482421875,\n            96.02874755859375,\n            474.7113952636719,\n            240.64328002929688\n        ]\n    ]\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiboy996%2Fvoc-mmdetection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faiboy996%2Fvoc-mmdetection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiboy996%2Fvoc-mmdetection/lists"}