Skip to content

Commit 9fb7f4a

Browse files
authored
feat: Add YOLO11 docs (#641)
1 parent a3a3482 commit 9fb7f4a

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

label_studio_ml/examples/yolo/README.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,23 @@ Here is an example of a prompt for this. It includes 1000 labels from YOLOv8 cla
223223
224224
</details>
225225
226-
## YOLOv5 and other YOLO versions
226+
## Supported YOLO Versions: YOLOv5, YOLO11, and others
227227
228-
YOLOv8 models have been successfully tested with this ML backend.
228+
- **YOLOv5**: This model is supported for object detection tasks. Make sure to specify `model_path="yolov5nu.pt"` (don't forget the **`u`**) to use the YOLOv5 model.
229+
230+
- **YOLOv8**: These models have been successfully tested with the current ML backend. Check the full list of [v8 models here](https://docs.ultralytics.com/models/yolov8/#supported-tasks-and-modes).
231+
232+
- **YOLO11**: YOLO11 models have also been successfully tested with this ML backend. Check the full list of [v11 models here](https://docs.ultralytics.com/models/yolo11/#supported-tasks-and-modes).
233+
234+
**Warning 1**: You must upgrade the `ultralytics` package to the latest version (`pip install -U ultralytics`) or rebuild the ML backend Docker from scratch (`docker-compose build --no-cache`) if you used it before the latest Ultralytics update on **Monday, September 30, 2024**.
235+
236+
**Warning 2**: YOLO11 models do not use the `v` in their naming convention. For example, use **`yolo11n.pt`** instead of `yolov11n.pt`, unlike the naming convention in YOLOv8.
237+
238+
- For a full list of supported YOLO versions and models, refer to the Ultralytics documentation:
239+
[Ultralytics Supported YOLO Models](https://docs.ultralytics.com/models/)
240+
241+
**Note**: Some YOLO models listed in the Ultralytics documentation have not been tested with this ML backend, but they might still work.
229242

230-
Attempts to run YOLOv5 were unsuccessful without modifications.
231-
It may be possible to run it by applying some changes, such as installing additional dependencies.
232-
The same applies to other YOLO models.
233243

234244
## Your own custom YOLO models
235245

@@ -248,6 +258,22 @@ You can load your own YOLO labels using the following steps:
248258
You can integrate your own custom-trained YOLOv8 models with the YOLO ML backend for Label Studio.
249259
Follow these detailed steps to set up your custom model in the ML backend Docker:
250260

261+
### Step 0: Install Label Studio and clone this Github repository
262+
263+
1. Install and run Label Studio (or see [more ways here](https://labelstud.io/guide/install)).
264+
265+
```
266+
pip install label-studio
267+
label-studio
268+
```
269+
270+
2. Clone the Label Studio ML backend repository and go to the `yolo` example folder:
271+
272+
```
273+
git clone https://github.com/HumanSignal/label-studio-ml-backend.git
274+
cd label-studio-ml-backend/examples/yolo
275+
```
276+
251277
### Step 1: Prepare your custom YOLOv8 model
252278

253279
Ensure that your custom YOLOv8 model is saved as a `.pt` file, which is the standard format for PyTorch models.

label_studio_ml/examples/yolo/control_models/timeline_labels.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ def create_timelines_trainable(self, video_path):
112112
return regions
113113

114114
def fit(self, event, data, **kwargs):
115+
if not self.trainable:
116+
logger.debug(
117+
'TimelineLabels model is in not trainable mode. '
118+
'Use model_trainable="true" to enable training.'
119+
)
120+
return
121+
115122
"""Fit the model."""
116123
if event == "START_TRAINING":
117124
# TODO: the full training makes a lot of sense here, but it's not implemented yet

label_studio_ml/examples/yolo/utils/neural_nets.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,13 @@ def get_label_map(self):
8383
return self.label_map
8484

8585
def save(self, path):
86-
torch.save(self, path)
86+
# ultralytics yolo11 patches torch.save to use dill,
87+
# however it leads to serialization errors,
88+
# so let's check for use_dill and disable it
89+
if 'use_dill' in torch.save.__code__.co_varnames:
90+
torch.save(self, path, use_dill=False)
91+
else:
92+
torch.save(self, path)
8793
logger.info(f"Model saved to {path}")
8894

8995
@classmethod

0 commit comments

Comments
 (0)