Skip to content

Mmdetection support - #173

Merged
SkalskiP merged 7 commits into
roboflow:mainfrom
hardikdava:mmdetection_support
Jul 18, 2023
Merged

Mmdetection support#173
SkalskiP merged 7 commits into
roboflow:mainfrom
hardikdava:mmdetection_support

Conversation

@hardikdava

Copy link
Copy Markdown
Contributor

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

SkalskiP commented Jul 4, 2023

Copy link
Copy Markdown
Collaborator

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

@hardikdava

hardikdava commented Jul 4, 2023

Copy link
Copy Markdown
Contributor Author

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

SkalskiP commented Jul 4, 2023

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Contributor Author

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

@SkalskiP

SkalskiP commented Jul 4, 2023

Copy link
Copy Markdown
Collaborator

@hardikdava you should be able to open it now

@hardikdava

Copy link
Copy Markdown
Contributor Author

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

@hardikdava

Copy link
Copy Markdown
Contributor 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
Copy Markdown
Contributor Author

@SkalskiP Please test it merge it.

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

Copy link
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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