Skip to content

Instantly share code, notes, and snippets.

@Tony607
Created June 23, 2019 13:43
Show Gist options
  • Save Tony607/5ea54b2b7067cdb0cccc36e90c83369b to your computer and use it in GitHub Desktop.
Save Tony607/5ea54b2b7067cdb0cccc36e90c83369b to your computer and use it in GitHub Desktop.
How to train an object detection model with mmdetection | DLology
%cd {mmdetection_dir}
from mmcv.runner import load_checkpoint
from mmdet.apis import inference_detector, show_result, init_detector
checkpoint_file = os.path.join(mmdetection_dir, work_dir, "latest.pth")
score_thr = 0.8
# build the model from a config file and a checkpoint file
model = init_detector(config_fname, checkpoint_file)
# test a single image and show the results
img = 'data/VOCdevkit/VOC2007/JPEGImages/15.jpg'
result = inference_detector(model, img)
show_result(img, result, model.CLASSES, score_thr=score_thr, out_file="result.jpg")
# Show the image with bbox overlays.
from IPython.display import Image
Image(filename='result.jpg')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment