|
| 1 | +import ComponentConfiguration from "@site/src/pages/components-explorer/_components/ComponentConfiguration"; |
| 2 | +import ComponentHeader from "@site/src/pages/components-explorer/_components/ComponentHeader"; |
| 3 | +import ComponentTroubleshooting from "@site/src/pages/components-explorer/_components/ComponentTroubleshooting/index.mdx"; |
| 4 | + |
| 5 | +import ComponentMetadata from "./_meta"; |
| 6 | +import config from "./config.json"; |
| 7 | + |
| 8 | +<ComponentHeader meta={ComponentMetadata} /> |
| 9 | + |
| 10 | +Ultralytics YOLO supports a wide range of models, from early versions like YOLOv3 to the latest YOLO11. |
| 11 | + |
| 12 | +:::warning |
| 13 | + |
| 14 | +This component has undergone limited testing. In addition to partial functional testing, only the following models have been confirmed to work: yolov5mu.pt, yolov8n, and yolo11s.pt |
| 15 | + |
| 16 | +::: |
| 17 | + |
| 18 | +:::note |
| 19 | + |
| 20 | +`yolo` component uses the official [`ultralytics`](https://docs.ultralytics.com/usage/python) python package. A GPU is used when available. |
| 21 | + |
| 22 | +::: |
| 23 | + |
| 24 | +:::info |
| 25 | + |
| 26 | +Models are not installed by default. See below for steps to define the model as well as make them available to Viseron. |
| 27 | + |
| 28 | +::: |
| 29 | + |
| 30 | +## Configuration |
| 31 | + |
| 32 | +<details> |
| 33 | + <summary>Configuration example</summary> |
| 34 | + |
| 35 | +```yaml title="/config/config.yaml" |
| 36 | +yolo: |
| 37 | + object_detector: |
| 38 | + model_path: /detectors/models/yolo/my_model.pt |
| 39 | + cameras: |
| 40 | + viseron_camera1: |
| 41 | + fps: 1 |
| 42 | + scan_on_motion_only: true |
| 43 | + log_all_objects: false |
| 44 | + labels: |
| 45 | + - label: dog |
| 46 | + confidence: 0.7 |
| 47 | + trigger_event_recording: false |
| 48 | + - label: cat |
| 49 | + confidence: 0.8 |
| 50 | +``` |
| 51 | +
|
| 52 | +</details> |
| 53 | +
|
| 54 | +<ComponentConfiguration meta={ComponentMetadata} config={config} /> |
| 55 | +
|
| 56 | +### Pre-trained models |
| 57 | +
|
| 58 | +These steps should assist in locating models, configuring your container to access them, and configuring Viseron to use them. |
| 59 | +
|
| 60 | +#### Finding models |
| 61 | +
|
| 62 | +Pre-trained YOLO models can be found online or you can train them yourself. |
| 63 | +
|
| 64 | +Examples of where to find pre-trained models: |
| 65 | +
|
| 66 | +- [Ultralytics](https://docs.ultralytics.com/models/) |
| 67 | +- [Roboflow](https://universe.roboflow.com/) |
| 68 | +- [Hugging Face](https://huggingface.co/models?pipeline_tag=object-detection&sort=trending) |
| 69 | +
|
| 70 | +There are models for many different tasks, including object detection. If you are not sure if there is a problem with Viseron please confirm your |
| 71 | +Viseron environment with a stock YOLO model from Ultralytics. For example: [yolov8n.pt](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolov8n.pt) |
| 72 | +
|
| 73 | +This component does not provide any training capabilities. See the [Ultralytics training](https://docs.ultralytics.com/modes/train/) documentation for more information. |
| 74 | +
|
| 75 | +#### Where to place models |
| 76 | +
|
| 77 | +Place your YOLO models in a directory of your choice. |
| 78 | +
|
| 79 | +There will be a later step to map the directory to the container. Therefore, choose a location supported by docker compose. If in doubt, do not use a SMB or NFS share. |
| 80 | +
|
| 81 | +#### Configuring Docker to make models available to Viseron |
| 82 | +
|
| 83 | +The following `docker-compose.yaml` snippet will show how to map the directory above to the container: |
| 84 | +```yaml title="/docker-compose.yaml" |
| 85 | + volumes: |
| 86 | + - {models path}:/detectors/models/yolo |
| 87 | +``` |
| 88 | + |
| 89 | +This is the only change to `docker-compose.yaml` required for this component. |
| 90 | + |
| 91 | +#### Configuring Viseron to use a model |
| 92 | + |
| 93 | +Modify the `model_path` setting in your Viseron `config.yaml` to point to one of the model(s) you installed. See the example above. |
| 94 | + |
| 95 | +Only one model can be used at a time. |
| 96 | + |
| 97 | +### Image resizing |
| 98 | + |
| 99 | +Images inferenced by the component are resized by the underlying `ultralytics` package to match the model's input size. |
| 100 | + |
| 101 | +There is no functionality to resize the image in the `yolo` component configuration before inferencing. |
| 102 | + |
| 103 | +### Labels |
| 104 | + |
| 105 | +When Viseron loads the model, it will print that model's labels to the log. |
| 106 | +``` |
| 107 | +cd {location of Viseron docker-compose.yaml} |
| 108 | +docker compose logs | grep "Labels" |
| 109 | +viseron | 2025-05-29 08:19:04.943 [INFO ] [viseron.components.yolo.object_detector] - Labels: {0: 'bicycle', 1: 'bird', 2: 'bus', 3: 'car', 4: 'cat', 5: 'dog', 6: 'motorcycle', 7: 'person', 8: 'truck', 9: 'squirrel', 10: 'car-light', 11: 'rabbit', 12: 'fox', 13: 'opossum', 14: 'skunk', 15: 'racoon'} |
| 110 | +``` |
| 111 | +
|
| 112 | +<ComponentTroubleshooting meta={ComponentMetadata} /> |
| 113 | +
|
0 commit comments