from mmdet.apis import DetInferencer
# We download the pre-trained checkpoints for inference and finetuning.
!mim download mmdet --config rtmdet_tiny_8xb32-300e_coco --dest ./checkpoints
# 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
# Initialize the DetInferencer
inferencer = DetInferencer(model_name, checkpoint, device)
# Use the detector to do inference
result = inferencer(img, out_dir='./output')