{"id":29085194,"url":"https://github.com/edgeimpulse/ml-block-yolov5","last_synced_at":"2025-10-24T17:35:16.592Z","repository":{"id":62312050,"uuid":"448348456","full_name":"edgeimpulse/ml-block-yolov5","owner":"edgeimpulse","description":"YOLOv5 transfer learning model for Edge Impulse","archived":false,"fork":false,"pushed_at":"2025-05-06T14:56:18.000Z","size":7461,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-06-15T10:42:13.737Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause-clear","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edgeimpulse.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,"zenodo":null}},"created_at":"2022-01-15T17:41:28.000Z","updated_at":"2025-05-06T14:56:22.000Z","dependencies_parsed_at":"2023-12-18T12:45:22.206Z","dependency_job_id":"9d85599e-f437-4cbe-b4f7-025b4c1551b5","html_url":"https://github.com/edgeimpulse/ml-block-yolov5","commit_stats":null,"previous_names":["edgeimpulse/ml-block-yolov5","edgeimpulse/yolov5"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/edgeimpulse/ml-block-yolov5","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgeimpulse%2Fml-block-yolov5","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgeimpulse%2Fml-block-yolov5/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgeimpulse%2Fml-block-yolov5/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgeimpulse%2Fml-block-yolov5/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edgeimpulse","download_url":"https://codeload.github.com/edgeimpulse/ml-block-yolov5/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgeimpulse%2Fml-block-yolov5/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262343949,"owners_count":23296422,"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":[],"created_at":"2025-06-27T22:31:41.430Z","updated_at":"2025-10-24T17:35:16.494Z","avatar_url":"https://github.com/edgeimpulse.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YOLOv5 transfer learning model for Edge Impulse\n\nThis repository contains the code to bring YOLOv5 models into Edge Impulse.\n\n## Built-in block no longer available\n\nAs of February 28, 2025, YOLOv5 is no longer available as a built-in block in Edge Impulse - due to a recent policy change on how we deal with hosting third party model training pipelines. No worries though, because this repository contains instructions on how to get YOLOv5 back in a few minutes. After following the instructions below you can select *Choose a different model*, re-pick YOLOv5, and you can retrain your model.\n\n## Adding YOLOv5 to your Edge Impulse account\n\nTo add this model to your Edge Impulse account (personal or enterprise organization):\n\n1. Install the [Edge Impulse CLI](https://docs.edgeimpulse.com/docs/edge-impulse-cli/cli-installation)\n2. Download this repository.\n3. Open a command prompt or terminal, navigate to the folder where you downloaded this repository, and run:\n\n    ```\n    edge-impulse-blocks init\n    edge-impulse-blocks push\n    ```\n\n4. In your Edge Impulse project go to **Create impulse \u003e Add learning block** and select **YOLOv5**. 🎉\n\n## Modifying the model code\n\nYou can use this repository as a basis to bring other types of ML base models into Edge Impulse. As a primer, read the [Custom learning blocks](https://docs.edgeimpulse.com/docs/edge-impulse-studio/learning-blocks/adding-custom-learning-blocks) page in the Edge Impulse docs.\n\nThe entrypoint for this ML block is [run.sh](run.sh). It does:\n\n1. Convert the training data / training labels into YOLOv5 format using [extract_dataset.py](extract_dataset.py).\n1. Train YOLOv5 model (using https://github.com/ultralytics/yolov5).\n1. Convert the YOLOv5 model into TFLite format.\n1. Done!\n\n\u003e **Note on epoch count:** YOLOv5 might take a while to converge, especially on large images. Play around with epoch count, or lower the resolution of your input until you have something that works.\n\n## Running the pipeline locally\n\nYou run this pipeline locally via Docker. This encapsulates all dependencies and packages for you.\n\n### Running via Docker\n\n1. Install [Docker Desktop](https://www.docker.com/products/docker-desktop/).\n2. Install the [Edge Impulse CLI](https://docs.edgeimpulse.com/docs/edge-impulse-cli/cli-installation).\n3. Create a new Edge Impulse project, and make sure the labeling method is set to 'Bounding boxes'.\n4. Add and label some data.\n5. Under **Create impulse** set the image size to e.g. 160x160, 320x320 or 640x640, add an 'Image' DSP block and an 'Object Detection' learn block.\n6. Open a command prompt or terminal window.\n7. Initialize the block:\n\n    ```\n    $ edge-impulse-blocks init\n    ```\n\n8. Fetch new data from an object detection project via:\n\n    ```\n    $ edge-impulse-blocks runner --download-data data/\n    ```\n\n9. Build the container:\n\n    ```\n    $ docker build -t yolov5 .\n    ```\n\n10. Run the container to test the script (you don't need to rebuild the container if you make changes):\n\n    ```\n    $ docker run --shm-size=1024m --rm -v $PWD:/scripts yolov5 --data-directory data/ --epochs 30 --model-size n --out-directory out/\n    ```\n\n    \u003e If you have an NVIDIA GPU, pass `--gpus all` to train on GPU.\n\n11. This creates an .onnx file and two .tflite files (both quantized and unquantized) in the 'out' directory.\n\n#### Adding extra dependencies\n\nIf you have extra packages that you want to install within the container, add them to `requirements.txt` and rebuild the container.\n\n## Fetching new data\n\nTo get up-to-date data from your project:\n\n1. Install the [Edge Impulse CLI](https://docs.edgeimpulse.com/docs/edge-impulse-cli/cli-installation) v1.16 or higher.\n2. Open a command prompt or terminal window.\n3. Fetch new data via:\n\n    ```\n    $ edge-impulse-blocks runner --download-data data/\n    ```\n\n    \u003e **Note:** To fetch data from another project, run ` edge-impulse-blocks runner --download-data data/ --clean`\n\n## Pushing the block back to Edge Impulse\n\nYou can also push this block back to Edge Impulse, that makes it available like any other ML block so you can retrain your model when new data comes in, or deploy the model to device. See [Docs \u003e Adding custom learning blocks](https://docs.edgeimpulse.com/docs/edge-impulse-studio/organizations/adding-custom-transfer-learning-models) for more information.\n\n1. Push the block:\n\n    ```\n    $ edge-impulse-blocks push\n    ```\n\n2. The block is now available under any of your projects, via  **Create impulse \u003e Add learning block**.\n\n## License notice\n\nThis repository is licensed under [The Clear BSD License](LICENSE), but is utilizing the GPLv3 licensed [ultralytics/yolov5](https://github.com/ultralytics/yolov5) repository (from a commit before this repository was changed to AGPL) at arm's length.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedgeimpulse%2Fml-block-yolov5","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedgeimpulse%2Fml-block-yolov5","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedgeimpulse%2Fml-block-yolov5/lists"}