You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

inference_demo.ipynb 1.1 MB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 1,
  6. "metadata": {},
  7. "outputs": [],
  8. "source": [
  9. "from mmdet.apis import init_detector, inference_detector, show_result_pyplot\n",
  10. "import mmcv"
  11. ]
  12. },
  13. {
  14. "cell_type": "code",
  15. "execution_count": 2,
  16. "metadata": {},
  17. "outputs": [],
  18. "source": [
  19. "config_file = '../configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'\n",
  20. "# download the checkpoint from model zoo and put it in `checkpoints/`\n",
  21. "# 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",
  22. "checkpoint_file = '../checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'"
  23. ]
  24. },
  25. {
  26. "cell_type": "code",
  27. "execution_count": 3,
  28. "metadata": {},
  29. "outputs": [],
  30. "source": [
  31. "# build the model from a config file and a checkpoint file\n",
  32. "model = init_detector(config_file, checkpoint_file, device='cuda:0')"
  33. ]
  34. },
  35. {
  36. "cell_type": "code",
  37. "execution_count": 4,
  38. "metadata": {},
  39. "outputs": [],
  40. "source": [
  41. "# test a single image\n",
  42. "img = 'demo.jpg'\n",
  43. "result = inference_detector(model, img)"
  44. ]
  45. },
  46. {
  47. "cell_type": "code",
  48. "execution_count": 5,
  49. "metadata": {},
  50. "outputs": [
  51. {
  52. "data": {

No Description

Contributors (1)