Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added YOLOv5 serverless function for auto labeling #4178

Merged
merged 3 commits into from
Jan 17, 2022

Conversation

wartek69
Copy link
Contributor

Motivation and context

Integration of YOLOv5 as a serverless nuclio function that can be used for auto-labeling. Ultralytics has released YOLOv5 a while ago and it's one of the most used computer vision libraries and therefore it would make sense to support it in CVAT. The integration is quite simple into CVAT as Ultralytics maintains a Pytorch Hub model (ultralytics/yolov5#36) and a docker image (https://hub.docker.com/r/ultralytics/yolov5).
Related issues from ultralytics repo: ultralytics/yolov5#5427

How has this been tested?

Automatic annotation was run using YOLOv5 on a custom dataset.
The serverless function was deployed using

nuctl deploy --project-name cvat \
  --path serverless/pytorch/ultralytics/yolov5/nuclio \
  --volume `pwd`/serverless/common:/opt/nuclio/common \
  --platform local

Then using the 'Automatic annotation' action the function was tested and the auto-generated labels were controlled to check that no coordinates misfit is happening.

Checklist

  • [ x] I submit my changes into the develop branch
  • [ x] I have added a description of my changes into CHANGELOG file
  • [ x] I have updated the documentation accordingly
  • [ x] I have added tests to cover my changes
  • [ x] I have linked related issues (read github docs)
  • [ x] I have increased versions of npm packages if it is necessary (cvat-canvas,
    cvat-core, cvat-data and cvat-ui)

License

  • [ x] I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • [x ] I have updated the license header for each file (see an example below)
# Copyright (C) 2022 Intel Corporation
#
# SPDX-License-Identifier: MIT

@nmanovic
Copy link
Contributor

@wartek69 , thanks for the contribution! Could you please add information about the model into README as well? https://github.com/openvinotoolkit/cvat#deep-learning-serverless-functions-for-automatic-labeling

@wartek69
Copy link
Contributor Author

@nmanovic I've added the model to the readme!

Copy link
Contributor

@nmanovic nmanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the contribution! Many users asked about YOLOv5 support.

@nmanovic nmanovic merged commit 182d941 into cvat-ai:develop Jan 17, 2022
@nmanovic nmanovic mentioned this pull request Mar 4, 2022
7 tasks
@simaiden
Copy link

I would like to add that if you want to deploy a custom model you should:

  • Copy the weights.pt file to /serverless/common
  • Edit main.py file with :
#Line 11
model_path = "/opt/nuclio/common/weights.pt"
model = torch.hub.load('ultralytics/yolov5', 'custom', path = model_path)  # or yolov5m, yolov5l, yolov5x, custom
  • It's important that the classes names defined in function.yaml file match with the classes defined when you train the model.

@martinerk0
Copy link

@simaiden Wow, thank you it works! From docs, it seemed I had to download weights into docker image or something, this was much nicer. @nmanovic It would be useful to put this into docs, usually people would want to run YOLO with custom weights without doing anything with docker/nuclio.

@nmanovic
Copy link
Contributor

@martinerk0 , could you please send us a PR with necessary updates for documentation?

@livan3li
Copy link

livan3li commented Jun 27, 2022

Motivation and context

Integration of YOLOv5 as a serverless nuclio function that can be used for auto-labeling. Ultralytics has released YOLOv5 a while ago and it's one of the most used computer vision libraries and therefore it would make sense to support it in CVAT. The integration is quite simple into CVAT as Ultralytics maintains a Pytorch Hub model (ultralytics/yolov5#36) and a docker image (https://hub.docker.com/r/ultralytics/yolov5). Related issues from ultralytics repo: ultralytics/yolov5#5427

How has this been tested?

Automatic annotation was run using YOLOv5 on a custom dataset. The serverless function was deployed using

nuctl deploy --project-name cvat \
  --path serverless/pytorch/ultralytics/yolov5/nuclio \
  --volume `pwd`/serverless/common:/opt/nuclio/common \
  --platform local

Then using the 'Automatic annotation' action the function was tested and the auto-generated labels were controlled to check that no coordinates misfit is happening.

Checklist

  • [ x] I submit my changes into the develop branch
  • [ x] I have added a description of my changes into CHANGELOG file
  • [ x] I have updated the documentation accordingly
  • [ x] I have added tests to cover my changes
  • [ x] I have linked related issues (read github docs)
  • [ x] I have increased versions of npm packages if it is necessary (cvat-canvas,
    cvat-core, cvat-data and cvat-ui)

License

  • [ x] I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • [x ] I have updated the license header for each file (see an example below)
# Copyright (C) 2022 Intel Corporation
#
# SPDX-License-Identifier: MIT

hi

how did you run this command.

nuctl deploy --project-name cvat \
--path serverless/pytorch/ultralytics/yolov5/nuclio \
--volume `pwd`/serverless/common:/opt/nuclio/common \
--platform local 

i cannot run it on windows 10. It throws an errors like this:

 C:\Users\user-name\cvat>nuctl deploy --project-name cvat \

Error - exec: "/bin/sh": file does not exist
    /nuclio/pkg/cmdrunner/shellrunner.go:96

Call stack:
stdout:

stderr:

    /nuclio/pkg/cmdrunner/shellrunner.go:96
Failed to get docker version
    /nuclio/pkg/dockerclient/shell.go:729
No docker client found
    /nuclio/pkg/dockerclient/shell.go:83
Failed to create docker client
    .../pkg/containerimagebuilderpusher/docker.go:31
Failed to create containerimagebuilderpusher
    /nuclio/pkg/platform/local/platform.go:88

@nfrvnikita
Copy link

Я хотел бы добавить, что если вы хотите развернуть пользовательскую модель, вам следует:

  • Скопируйте weights.pt файл в / бессерверный / общий
  • Редактировать main.py файл с :
torch
= model "/opt/nuclio/common/weights.pt"
= model_path #Строка 11.hub.load('ultralytics/yolov5', 'пользовательский', путь  = model_path) # или yolov5m, yolov5l, yolov5x, пользовательский
  • Важно, чтобы имена классов были определены в функции.файл yaml соответствует классам, определенным при обучении модели.

Hi, how i can copy my weights to /serversless/common?
docker cp?

@simaiden
Copy link

Я хотел бы добавить, что если вы хотите развернуть пользовательскую модель, вам следует:

  • Скопируйте weights.pt файл в / бессерверный / общий
  • Редактировать main.py файл с :
torch
= model "/opt/nuclio/common/weights.pt"
= model_path #Строка 11.hub.load('ultralytics/yolov5', 'пользовательский', путь  = model_path) # или yolov5m, yolov5l, yolov5x, пользовательский
  • Важно, чтобы имена классов были определены в функции.файл yaml соответствует классам, определенным при обучении модели.

Hi, how i can copy my weights to /serversless/common? docker cp?

Just copy in your os filesystem, cvat mount the entire folder into the docker container

@chang50961471
Copy link

How to clean up disk space by automatically annotating whether it will occupy a large amount of disk space

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants