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

Yolov8 Object Detection PyTorch tutorial #1030

Merged
merged 11 commits into from Apr 7, 2024
Merged

Conversation

lapid92
Copy link
Collaborator

@lapid92 lapid92 commented Apr 2, 2024

Pull Request Description:

Add Yolov8 Object Detection PyTorch tutorial using multiclass_nms from sony_cusom_layers

Checklist before requesting a review:

  • I set the appropriate labels on the pull request.
  • I have added/updated the release note draft (if necessary).
  • I have updated the documentation to reflect my changes (if necessary).
  • All function and files are well documented.
  • All function and classes have type hints.
  • There is a licenses in all file.
  • The function and variable names are informative.
  • I have checked for code duplications.
  • I have added new unittest (if necessary).



def yolov8_preprocess(x: np.ndarray, img_mean: float = 0.0, img_std: float = 255.0, pad_values: int = 114,
size: Tuple[int, int] = (640, 640)) -> np.ndarray:
Copy link
Collaborator

Choose a reason for hiding this comment

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

we have a problem of code duplication. I think eventually we will need to create a preprocess folder, that contains the preprocess methods. for now, maybe just unify the 2 functions to 1 function of yolov8_preprocess...

from model_compression_toolkit.core.pytorch.pytorch_device_config import get_working_device


def model_predict(model: Any,
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe to include this function in the yolov8.py file? I'm thinking maybe we should create a template for each model (a class) that includes the required functions.. let's do it in a different PR

"metadata": {},
"outputs": [],
"source": [
"from tutorials.mct_model_garden.models_pytorch.yolov8.yolov8 import DetectionModelPyTorch, yaml_load\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

space with empty line

"source": [
"from tutorials.mct_model_garden.models_pytorch.yolov8.yolov8 import DetectionModelPyTorch, yaml_load\n",
"cfg_dict = yaml_load(\"./local_mct/tutorials/mct_model_garden/models_pytorch/yolov8/yolov8n.yaml\", append_filename=True) # model dict\n",
"model = DetectionModelPyTorch.from_pretrained(\"SSI-DNN/pytorch_yolov8n_640x640_bb_decoding\", cfg=cfg_dict)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you check if passing the yaml is a must? if not better to remove it.

"!pip install onnx\n",
"!pip install -q pycocotools\n",
"!pip install huggingface-hub==0.21.3\n",
"!pip install --pre sony-custom-layers-dev==0.2.0.dev1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you check if the version limitation is required? if not better to remove it.

},
"source": [
" Clone a copy of the [MCT](https://github.com/sony/model_optimization) (Model Compression Toolkit) into your current directory. This step ensures that you have access to [MCT Models Library](https://github.com/sony/model_optimization/tree/main/tutorials/mct_model_garden) folder which contains all the necessary utility functions for this tutorial.\n",
" **It's important to note that we use the most up-to-date MCT code available.**"
Copy link
Collaborator

Choose a reason for hiding this comment

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

MCT Models Library --> MCT Models Garden

@lapid92 lapid92 merged commit 11d8348 into sony:main Apr 7, 2024
26 of 27 checks passed
samuel-wj-chapman pushed a commit to samuel-wj-chapman/model_optimization that referenced this pull request Apr 8, 2024
* Yolov8 Object Detection PyTorch tutorial
* Add Yolov8 Object Detection to the PyTorch MCT Model Garden
* The  PyTorch implementation of Yolov8n object detection model, following https://github.com/ultralytics/ultralytics. This implementation includes a slightly modified version of the yolov8 detection-head optimized for model quantization.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants