supervision icon indicating copy to clipboard operation
supervision copied to clipboard

Mmdetection mask

Open DrawingProcess opened this issue 1 year ago • 4 comments

Description

See #765

List any dependencies that are required for this change.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How has this change been tested, please provide a testcase or example of how you tested the change?

Try putting in a configuration without a mask and a config with a mask to see if the value fits well

Any specific deployment considerations

Nothing

Docs

There is nothing special

DrawingProcess avatar Jan 22 '24 23:01 DrawingProcess

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jan 22 '24 23:01 CLAassistant

Hi @DrawingProcess 👋🏻 ! Thanks a lot for your interest in supervision. Could you provide an example that we could use to test your changes?

SkalskiP avatar Jan 23 '24 11:01 SkalskiP

Here is a test code.

First of all, You have to ready for mmdetection Environment Then modify datapath(datset, sub(coco format)) of the below code.

test code

import random
from mmdet.apis import init_detector, inference_detector

import supervision as sv

from mmengine import Config

# without mask model
# cfg = Config.fromfile('checkpoint/rtmdet_s_8xb32-300e_coco.py')
# checkpoint_file = 'checkpoint/rtmdet_s_8xb32-300e_coco_20220905_161602-387a891e.pth'

# with mask model
cfg = Config.fromfile('checkpoint/rtmdet-ins_s_8xb32-300e_coco.py')
checkpoint_file = 'checkpoint/rtmdet-ins_s_8xb32-300e_coco_20221121_212604-fdc5d7ec.pth'

dataset = "/home/avs/dataset/train_exd/"
sub = "EVT_20230715_112856_F_trim"

ds = sv.DetectionDataset.from_coco(
    images_directory_path=dataset + sub,
    annotations_path=dataset + sub + ".json",
)

images = list(ds.images.values())

model = init_detector(cfg, checkpoint_file)

# image = random.choice(images)
with sv.ImageSink(target_dir_path=f"/home/avs/dataset/train_vis_rtmdet/{sub}", overwrite=True) as sink:
    for i, image in enumerate(images):
        result = inference_detector(model, image)
        detections = sv.Detections.from_mmdetection(result)
        print(detections)

Result

without mask model mmdetection_masknone with mask model mmdetection_mask

DrawingProcess avatar Jan 23 '24 23:01 DrawingProcess

Hi @DrawingProcess 👋🏻 Thank you very much for your contribution! Would it be possible for you to share a Google Colab link for testing purposes?

Establishing a local testing environment could be quite time-consuming, and that time could be more effectively allocated towards developing new features or enhancing our documentation. A Google Colab link would significantly streamline our process, enabling us to integrate this pull request more swiftly.

We greatly appreciate your understanding and support in this matter.

SkalskiP avatar Jan 25 '24 15:01 SkalskiP