{"id":21503568,"url":"https://github.com/LIU42/TrafficRules","last_synced_at":"2025-07-15T23:31:38.620Z","repository":{"id":219227305,"uuid":"748255871","full_name":"LIU42/TrafficRules","owner":"LIU42","description":"基于 YOLO11 的路口交通信号灯通行规则识别","archived":false,"fork":false,"pushed_at":"2025-05-24T08:17:41.000Z","size":579,"stargazers_count":27,"open_issues_count":4,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-24T09:24:04.952Z","etag":null,"topics":["autonomous-driving","computer-vision","object-detection","onnxruntime","opencv","traffic","traffic-light-detection","traffic-rules","yolo"],"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":"2024-01-25T15:47:10.000Z","updated_at":"2025-05-24T08:17:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"3b04fdcd-942a-4b13-9606-c63e1794aec2","html_url":"https://github.com/LIU42/TrafficRules","commit_stats":null,"previous_names":["liu42/trafficsignal","liu42/trafficrules"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/LIU42/TrafficRules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIU42%2FTrafficRules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIU42%2FTrafficRules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIU42%2FTrafficRules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIU42%2FTrafficRules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LIU42","download_url":"https://codeload.github.com/LIU42/TrafficRules/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIU42%2FTrafficRules/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265467485,"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":["autonomous-driving","computer-vision","object-detection","onnxruntime","opencv","traffic","traffic-light-detection","traffic-rules","yolo"],"created_at":"2024-11-23T18:24:12.514Z","updated_at":"2025-07-15T23:31:38.610Z","avatar_url":"https://github.com/LIU42.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Traffic Rules\n\n*\u003cu\u003ev2.0.0 新变化：使用 YOLO11 以及一个更加丰富的数据集训练模型，对原来目标检测和信号分类两个步骤进行整合，去除了在大部分情况下冗余的过滤筛选，实现交通信号灯识别一步到位，得到的模型识别准确率和推理效率均有少量的提升，且更加易于部署。\u003c/u\u003e*\n\n## 项目简介\n\n本项目为基于 YOLO11 的路口交通信号灯通行规则识别，其中通行规则识别分为以下两个步骤：\n\n1. **目标检测**，采用 YOLO11 目标检测模型，识别图像中交通信号灯的位置、颜色以及形状（包括圆形、左箭头、上箭头和右箭头）。\n\n2. **规则解析**，对图像中检测出来的交通信号灯，解析其表示的通行规则（即能否直行、能否左转和能否右转）。\n   \n   - 圆形的信号灯能够控制三个方向的通行规则，优先级较低。\n   \n   - 箭头形的信号灯仅能控制对应方向的通行规则，但优先级较高。\n   \n   此外，若无明确信号，即没有红色的右箭头信号灯，右转默认视为允许通行。\n\n## 效果展示\n\n![](assets/example.jpg)\n\n## 性能评估\n\n模型的输入图像尺寸固定为 640 x 480，使用 [YOLO11n](https://docs.ultralytics.com/zh/models/yolo11/) 模型训练，在当前数据集下信号灯目标检测准确性指标如下。\n\n| Class | Precision | Recall | mAP50 | mAP50-95 |\n| ----- | --------- | ------ | ----- | -------- |\n| ALL   | 0.97      | 0.971  | 0.989 | 0.89     |\n| F0    | 0.99      | 1      | 0.995 | 0.871    |\n| F1    | 1         | 0.981  | 0.995 | 0.872    |\n| L0    | 0.981     | 0.985  | 0.994 | 0.912    |\n| L1    | 0.982     | 1      | 0.995 | 0.915    |\n| S0    | 1         | 0.817  | 0.944 | 0.878    |\n| S1    | 1         | 0.987  | 0.995 | 0.885    |\n| R0    | 0.815     | 1      | 0.995 | 0.914    |\n| R1    | 0.993     | 1      | 0.995 | 0.876    |\n\n*\u003cu\u003e注：本项目训练用的数据集规模较小，在真实环境下的鲁棒性可能不够理想。\u003c/u\u003e*\n\n## 使用说明\n\n首先安装依赖工具包，本项目采用 [ONNX Runtime](https://onnxruntime.ai/) 部署模型推理，如果对 Execution Provider 有特殊需求，请参阅 [官方文档](https://onnxruntime.ai/docs/execution-providers/) 进行配置。\n\n```shell-session\npip install -r requirements.txt\n```\n\n准备好待识别图像，识别程序接受的图像尺寸为 640x480，在本项目 Releases 中下载我训练好的模型权重文件，解压到 inferences/models 目录下，运行主程序 main.py 即可，其命令行参数的含义如下，其中输入图像文件路图像文件路径数量保持一致：\n\n| 参数名       | 简化参数名 | 参数描述                       |\n|:---------:|:-----:|:--------------------------:|\n| --sources | -s    | 输入预测图像文件路径序列，不同的文件路径以空格分隔。 |\n| --outputs | -o    | 输出结果图像文件路径序列，不同的文件路径以空格分隔。 |\n\n下面是一个运行示例。\n\n```shell-session\npython main.py --sources \"1.jpg\" \"2.jpg\" --outputs \"1.jpg\" \"2.jpg\"\n```\n\n本项目的识别程序被设计为一个即插即用的 Python 模块，可以将 inferences 模块完整拷贝到其他项目根目录下，配置好环境并安装好相关的依赖，参考 main.py 中的调用方式。\n\n通行规则识别模块默认的配置文件为 inferences/configs/config.toml，其中各个属性描述如下：\n\n| 属性名            | 属性描述                                      |\n|:--------------:|:-----------------------------------------:|\n| providers      | 模型推理 ONNX Runtime Execution Providers 列表。 |\n| precision      | 推理运算精度，可取 \"fp32\"（单精度）或 \"fp16\"（半精度）。       |\n| model-path     | 推理模型加载路径。                                 |\n| conf-threshold | 目标检测置信度阈值。                                |\n| iou-threshold  | 目标检测非极大值抑制 IoU 阈值。                        |\n\n如果需要使用自己的数据集训练模型，则需要安装 [Ultralytics](https://docs.ultralytics.com/) 框架，参照 [官方文档](https://docs.ultralytics.com/) 进行模型的训练，最后将模型转换为 ONNX 格式进行部署即可。\n\n```shell-session\npip install ultralytics\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLIU42%2FTrafficRules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLIU42%2FTrafficRules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLIU42%2FTrafficRules/lists"}