This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some basic setup: | |
# Setup detectron2 logger | |
import detectron2 | |
from detectron2.utils.logger import setup_logger | |
setup_logger() | |
# import some common libraries | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install dependencies: | |
!pip install pyyaml==5.1 pycocotools>=2.0.1 | |
import torch, torchvision | |
print(torch.__version__, torch.cuda.is_available()) | |
!gcc - version | |
# opencv is pre-installed on colab | |
# install detectron2: (colab has CUDA 10.1 + torch 1.6): | |
# See https://detectron2.readthedocs.io/tutorials/install.html for instructions | |
assert torch.__version__.startswith("1.6") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#getting Image from COCO dataset | |
!wget http://images.cocodataset.org/val2017/000000439715.jpg -q -O input.jpg | |
im = cv2.imread("./input.jpg") | |
cv2_imshow(im) | |
#Creating a detectron2 config and a detectron2 `DefaultPredictor` to run inference on this image. | |
cfg = get_cfg() | |
# add project-specific config (e.g., TensorMask) here if you're not running a model in detectron2's core library | |
cfg.merge_from_file(model_zoo.get_config_file("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml")) | |
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5 # set threshold for this model |