Skip to content

Mmdetection support #173

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

Merged
merged 7 commits into from
Jul 18, 2023
Merged

Mmdetection support #173

merged 7 commits into from
Jul 18, 2023

Conversation

hardikdava
Copy link
Collaborator

Description

Support for MMDetection inference result. This method also supports for mmyolo

Get more information on inference datatype from here

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Docs

  • Docs updated? What were the changes:

@SkalskiP
Copy link
Collaborator

SkalskiP commented Jul 4, 2023

@hardikdava, will it work with any MMDetection object detector or just selected ones?

@hardikdava
Copy link
Collaborator Author

hardikdava commented Jul 4, 2023

It will work with all models from mmdetection and mmyolo. These two framework consists all object detection models. Implemented method works with all these models. Later, I will method to work with segmentation also.

@SkalskiP
Copy link
Collaborator

SkalskiP commented Jul 4, 2023

Hi @hardikdava 👋🏻! I tried to test this feature, but it failed. Could you take a look at this notebook https://colab.research.google.com/drive/1HHODtyNlhoXG3etx_fjaU4-B6FsUYHhG, and let me know if I did something incorrectly or if we don't cover that case?

@hardikdava
Copy link
Collaborator Author

@SkalskiP can you approve my request to open the notebook?

@SkalskiP
Copy link
Collaborator

SkalskiP commented Jul 4, 2023

@hardikdava you should be able to open it now

@hardikdava
Copy link
Collaborator Author

@SkalskiP I will finish this by the end of the day.

@hardikdava
Copy link
Collaborator Author

@SkalskiP Apparently, mmyolo and mmdetection uses two different API for inference. But the output format is same for both. Here is colab notebook for example. I tested for mmdetection and mmyolo model inference instruction is different for mmyolo but inference results successfully converted using sv.Detections.from_mmdetection() method.

# mmdetection method:
from mmdet.apis import DetInferencer
img_path = './demo/demo.jpg'
# Choose to use a config
model_name = 'rtmdet_tiny_8xb32-300e_coco'
# Setup a checkpoint file to load
checkpoint = './checkpoints/rtmdet_tiny_8xb32-300e_coco_20220902_112414-78e30dcc.pth'
# Set the device to be used for evaluation
device = 'cuda:0'

# Initialize the DetInferencer
inferencer = DetInferencer(model_name, checkpoint, device)

# Use the detector to do inference
result = inferencer(img_path, out_dir='./output', return_datasample=True)["predictions"][0]
# mmyolo method:
from mmdet.apis import inference_detector, init_detector #mmyolo uses api from mmdet

# Choose to use a config
config = '/content/mmyolo/checkpoints/yolov5_s-v61_syncbn_fast_8xb16-300e_coco.py'
# Setup a checkpoint file to load
checkpoint = '/content/mmyolo/checkpoints/yolov5_s-v61_syncbn_fast_8xb16-300e_coco_20220918_084700-86e02187.pth'

# Set the device to be used for evaluation
device = 'cuda:0'

# Initialize the DetInferencer
model = init_detector(config, checkpoint, device=device, cfg_options={})


# Use the detector to do inference
img_path = './demo/demo.jpg'
result = inference_detector(model, img_path)

@hardikdava
Copy link
Collaborator Author

@SkalskiP Please test it merge it.

@SkalskiP SkalskiP added this to the version: 0.12.0 milestone Jul 18, 2023
@SkalskiP
Copy link
Collaborator

Hi @hardikdava 👋🏻 thanks for creating Colab. It was super helpful. Merging.

@SkalskiP SkalskiP merged commit 22d82c3 into roboflow:main Jul 18, 2023
@hardikdava hardikdava deleted the mmdetection_support branch July 18, 2023 13:28
@hardikdava
Copy link
Collaborator Author

Hi @hardikdava 👋🏻 thanks for creating Colab. It was super helpful. Merging.

yeah, I like your idea about it. It is very easy to test it. I did the same for paddleDet feature.

@SkalskiP
Copy link
Collaborator

I think it would make sense to have a demo Google Colab as a requirement when we implement new features. It makes testing super easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
version: 0.12.0 Feature to be added in `0.12.0` release
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants