{"id":21235988,"url":"https://github.com/lddl/road-anomaly-detection-train","last_synced_at":"2025-03-15T02:45:06.581Z","repository":{"id":245616354,"uuid":"818756285","full_name":"LdDl/road-anomaly-detection-train","owner":"LdDl","description":"Training object detector for road accidents detection","archived":false,"fork":false,"pushed_at":"2024-06-26T10:08:44.000Z","size":25606,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T18:49:13.294Z","etag":null,"topics":["computer-vision","neural-network","object-detection","yolov8"],"latest_commit_sha":null,"homepage":"https://github.com/LdDl/road-anomaly-detection","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/LdDl.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}},"created_at":"2024-06-22T19:14:41.000Z","updated_at":"2024-06-26T10:08:47.000Z","dependencies_parsed_at":"2024-06-26T11:13:45.002Z","dependency_job_id":null,"html_url":"https://github.com/LdDl/road-anomaly-detection-train","commit_stats":null,"previous_names":["lddl/road-anomaly-detection-train"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Froad-anomaly-detection-train","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Froad-anomaly-detection-train/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Froad-anomaly-detection-train/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Froad-anomaly-detection-train/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LdDl","download_url":"https://codeload.github.com/LdDl/road-anomaly-detection-train/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243676716,"owners_count":20329432,"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":["computer-vision","neural-network","object-detection","yolov8"],"created_at":"2024-11-21T00:05:33.220Z","updated_at":"2025-03-15T02:45:06.561Z","avatar_url":"https://github.com/LdDl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Training object detector for road accidents detection\n\n## Table of Contents\n- [About](#about)\n- [Pretrained models](#pretrained-models)\n- [Usage](#usage)\n- [References](#references)\n\n## About\nIt is just bunch of scripts to train road accidents detector for my pet-project written in Rust programming languages: https://github.com/LdDl/road-anomaly-detection\n\nThere are two scripts in this repository:\n- `download.py` to download dataset of interest;\n- `train.py` to run training process; (w.i.p)\n\n## Pretrained models\n\nIf you want just to download pretrained models here are links:\n- YOLOv8 nano - [Best weights (ONNX)](https://github.com/LdDl/road-anomaly-detection-train/releases/download/v0.2.0/best_nano.onnx), [Best weights (Pytorch)](https://github.com/LdDl/road-anomaly-detection-train/releases/download/v0.2.0/best_nano.pt) [Last weights (Pytorch)](https://github.com/LdDl/road-anomaly-detection-train/releases/download/v0.2.0/last_nano.pt)\n  Parameters:\n  - Image size: 608x608\n  - Batch size: 16\n  - Epochs: 300\n  - Cache images: yes\n\n  \u003cdetails\u003e\n    \u003csummary\u003eTraining results (images, CSV)\u003c/summary\u003e\n    \n    Training and validation batches examples are [here](runs/detect/nano/)\n\n    | \u003cimg src=\"runs/detect/nano/results.png\" width=\"640\"\u003e | \n    |:--:| \n    | Results . Corresponding CSV is [here](runs/detect/nano/results.csv) |\n\n    | \u003cimg src=\"runs/detect/nano/confusion_matrix.png\" width=\"640\"\u003e | \n    |:--:| \n    | *Confusion matrix* |\n\n    | \u003cimg src=\"runs/detect/nano/confusion_matrix_normalized.png\" width=\"640\"\u003e | \n    |:--:| \n    | *Normalized confusion matrix* |\n  \n    | \u003cimg src=\"runs/detect/nano/F1_curve.png\" width=\"640\"\u003e | \n    |:--:| \n    | *F1 Curve* |\n\n    | \u003cimg src=\"runs/detect/nano/P_curve.png\" width=\"640\"\u003e | \n    |:--:| \n    | *P Curve* |\n\n    | \u003cimg src=\"runs/detect/nano/R_curve.png\" width=\"640\"\u003e | \n    |:--:| \n    | *R Curve* |\n\n    | \u003cimg src=\"runs/detect/nano/PR_curve.png\" width=\"640\"\u003e | \n    |:--:| \n    | *PR Curve* |\n\n    | \u003cimg src=\"runs/detect/nano/labels.jpg\" width=\"640\"\u003e | \n    |:--:| \n    | *Labels* |\n\n    | \u003cimg src=\"runs/detect/nano/labels_correlogram.jpg\" width=\"640\"\u003e | \n    |:--:| \n    | *Labels correlogram* |\n\n  \u003c/details\u003e\n\n- YOLOv8 small - [Best weights (ONNX)](https://github.com/LdDl/road-anomaly-detection-train/releases/download/v0.2.0/best_small.onnx), [Best weights (Pytorch)](https://github.com/LdDl/road-anomaly-detection-train/releases/download/v0.2.0/best_small.pt) [Last weights (Pytorch)](https://github.com/LdDl/road-anomaly-detection-train/releases/download/v0.2.0/last_small.pt)\n\n  Parameters:\n  - Image size: 608x608\n  - Batch size: 16\n  - Epochs: 300\n  - Cache images: yes\n\n  \u003cdetails\u003e\n    \u003csummary\u003eTraining results (images, CSV)\u003c/summary\u003e\n    \n    Training and validation batches examples are [here](runs/detect/small/)\n\n    | \u003cimg src=\"runs/detect/small/results.png\" width=\"640\"\u003e | \n    |:--:| \n    | Results . Corresponding CSV is [here](runs/detect/small/results.csv) |\n\n    | \u003cimg src=\"runs/detect/small/confusion_matrix.png\" width=\"640\"\u003e | \n    |:--:| \n    | *Confusion matrix* |\n\n    | \u003cimg src=\"runs/detect/small/confusion_matrix_normalized.png\" width=\"640\"\u003e | \n    |:--:| \n    | *Normalized confusion matrix* |\n  \n    | \u003cimg src=\"runs/detect/small/F1_curve.png\" width=\"640\"\u003e | \n    |:--:| \n    | *F1 Curve* |\n\n    | \u003cimg src=\"runs/detect/small/P_curve.png\" width=\"640\"\u003e | \n    |:--:| \n    | *P Curve* |\n\n    | \u003cimg src=\"runs/detect/small/R_curve.png\" width=\"640\"\u003e | \n    |:--:| \n    | *R Curve* |\n\n    | \u003cimg src=\"runs/detect/small/PR_curve.png\" width=\"640\"\u003e | \n    |:--:| \n    | *PR Curve* |\n\n    | \u003cimg src=\"runs/detect/small/labels.jpg\" width=\"640\"\u003e | \n    |:--:| \n    | *Labels* |\n\n    | \u003cimg src=\"runs/detect/small/labels_correlogram.jpg\" width=\"640\"\u003e | \n    |:--:| \n    | *Labels correlogram* |\n\n  \u003c/details\u003e\n\n- YOLOv8 medium - @todo train\n- YOLOv8 large - @todo train\n- YOLOv8 extra large - [Best weights (ONNX)](https://github.com/LdDl/road-anomaly-detection-train/releases/download/v0.2.0/best_extra_large.onnx), [Best weights (Pytorch)](https://github.com/LdDl/road-anomaly-detection-train/releases/download/v0.2.0/best_extra_large.pt) [Last weights (Pytorch)](https://github.com/LdDl/road-anomaly-detection-train/releases/download/v0.2.0/last_extra_large.pt)\n\n  Parameters:\n  - Image size: 608x608\n  - Batch size: 16\n  - Epochs: 300\n  - Cache images: yes\n\n  \u003cdetails\u003e\n    \u003csummary\u003eTraining results (images, CSV)\u003c/summary\u003e\n    \n    Training and validation batches examples are [here](runs/detect/extra_large/)\n\n    | \u003cimg src=\"runs/detect/extra_large/results.png\" width=\"640\"\u003e | \n    |:--:| \n    | Results . Corresponding CSV is [here](runs/detect/extra_large/results.csv) |\n\n    | \u003cimg src=\"runs/detect/extra_large/confusion_matrix.png\" width=\"640\"\u003e | \n    |:--:| \n    | *Confusion matrix* |\n\n    | \u003cimg src=\"runs/detect/extra_large/confusion_matrix_normalized.png\" width=\"640\"\u003e | \n    |:--:| \n    | *Normalized confusion matrix* |\n  \n    | \u003cimg src=\"runs/detect/extra_large/F1_curve.png\" width=\"640\"\u003e | \n    |:--:| \n    | *F1 Curve* |\n\n    | \u003cimg src=\"runs/detect/extra_large/P_curve.png\" width=\"640\"\u003e | \n    |:--:| \n    | *P Curve* |\n\n    | \u003cimg src=\"runs/detect/extra_large/R_curve.png\" width=\"640\"\u003e | \n    |:--:| \n    | *R Curve* |\n\n    | \u003cimg src=\"runs/detect/extra_large/PR_curve.png\" width=\"640\"\u003e | \n    |:--:| \n    | *PR Curve* |\n\n    | \u003cimg src=\"runs/detect/extra_large/labels.jpg\" width=\"640\"\u003e | \n    |:--:| \n    | *Labels* |\n\n    | \u003cimg src=\"runs/detect/extra_large/labels_correlogram.jpg\" width=\"640\"\u003e | \n    |:--:| \n    | *Labels correlogram* |\n\n  \u003c/details\u003e\n\n## Usage\n* Clone the repository and navigate to root folder:\n  ```shell\n  git clone https://github.com/LdDl/road-anomaly-detection-train.git\n  cd road-anomaly-detection-train\n  ```\n\n* Install dependencies\n  ```shell\n  pip3 install -r requirements.txt\n  ```\n\n* Navigate to selected dataset. In this case the link is:\n  ```\n  https://universe.roboflow.com/accident-detection-ffdrf/accident-detection-8dvh5\n  ```\n\n  Click `Download` button:\n\n  \u003cimg src=\"docs/screenshot_2.png\" width=\"320\"\u003e\n\n* Navigate to `Terminal` tab and get dataset ID and unique key to download it.\n\n  \u003cimg src=\"docs/screenshot_1.png\" width=\"480\"\u003e\n\n* Run `download.py` script\n  ```shell\n  export DATASET_ID=YOUR-DATASET-ID\n  export ROBOFLOW_KEY=YOUR-ACCOUNT-KEY\n  \n  python3 download.py --dataset_id $DATASET_ID --key $ROBOFLOW_KEY --output dataset.zip\n  ```\n\n  You can adjust classes if you need to in lines [119](download.py#L119) and [124](download.py#L124):\n    - Undefined classes would be marked as (max class ID + 1).\n    - Warning: Re-labeled annotations would be stored in `/train/labels`, `/test/labels` and `/valid/labels`. Source labels would be stored in `/train/labels_source`, `/test/labels_source` and `/valid/labels_source` respectively.\n\n\n* Run `train.py` script\n  ```shell\n  python3 train.py --cache_images t --model_size n --image_size 608 --yaml_path extracted_dataset --batch_size 16 --epochs 300\n  ```\n\n  When training is done you can extract both ONNX and Pytorch weights from `run` directory which would be generated during training process.\n\n## References\n* Developers of YOLOv8 - https://github.com/ultralytics/ultralytics. If you are aware of some original papers for YOLOv8 architecture, please contact me to mention it in this README.\n* Dataset source https://universe.roboflow.com/accident-detection-ffdrf/accident-detection-8dvh5\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flddl%2Froad-anomaly-detection-train","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flddl%2Froad-anomaly-detection-train","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flddl%2Froad-anomaly-detection-train/lists"}