seblful / label-studio-yolov8-backend

ML backend for the Label Studio tool. The backend uses the YOLOv8 model for instance image segmentation or object detection.
52 stars 15 forks source link

Object detection doesnt work #4

Closed justdimaa closed 7 months ago

justdimaa commented 7 months ago

hi, I created a project in Label Studio with the following template:

<View>
  <Image name="image" value="$image"/>
  <RectangleLabels name="label" toName="image">
    <Label value="player" background="green"/>
  </RectangleLabels>
</View>

threw in a few pictures, labelled them, exported the data, trained my model with:

yolo train detect data=mc-player.yaml device=0 epochs=100

put the best.pt -> best_det.pt in the ML project folder, run the model_det.py (renamed to model.py), tried to connect add the model to LS, but I get the following error thrown in the console:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/label_studio_ml/exceptions.py", line 39, in exception_f
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/label_studio_ml/api.py", line 70, in _setup
    model = _manager.fetch(project, schema, force_reload,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/label_studio_ml/model.py", line 537, in fetch
    model = cls.model_class(label_config=label_config, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/model.py", line 36, in __init__
    self.from_name, self.to_name, self.value, self.classes = get_single_tag_keys(
                                                             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/label_studio_ml/utils.py", line 24, in get_single_tag_keys
    assert info['type'] == control_type, 'Label config has control tag "<' + info['type'] + '>" but "<' + control_type + '>" is expected for this model.'  # noqa
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Label config has control tag "<RectangleLabels>" but "<PolygonLabels>" is expected for this model.

The same procedure works with image segmentation when I train my model with yolo train segment ... instead of detect, use model.py (the segment py) and PolygonLabels in LS.

seblful commented 7 months ago

Try to recreate docker image and containers if you didn't, after any changes it should be new container with new model or code

justdimaa commented 7 months ago

thanks for your help, I decided to create my own backend in rust, because I couldn't figure out what it was, even after rebuilding the images