|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [],
- "source": [
- "from mmdet.apis import init_detector, inference_detector, show_result_pyplot\n",
- "import mmcv"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {},
- "outputs": [],
- "source": [
- "config_file = '../configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'\n",
- "# download the checkpoint from model zoo and put it in `checkpoints/`\n",
- "# url: https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth\n",
- "checkpoint_file = '../checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {},
- "outputs": [],
- "source": [
- "# build the model from a config file and a checkpoint file\n",
- "model = init_detector(config_file, checkpoint_file, device='cuda:0')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [],
- "source": [
- "# test a single image\n",
- "img = 'demo.jpg'\n",
- "result = inference_detector(model, img)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {},
- "outputs": [
- {
- "data": {
|