Skip to content

Instantly share code, notes, and snippets.

View PallawiSinghal's full-sized avatar
🎯
Focusing

Pallawi Rajendra PallawiSinghal

🎯
Focusing
View GitHub Profile
import the COCO Evaluator to use the COCO Metrics
from detectron2.config import get_cfg
from detectron2.engine import DefaultPredictor
from point_rend.config import add_pointrend_config #most important
from detectron2.data import build_detection_test_loader
from detectron2.data.datasets import register_coco_instances
from detectron2.evaluation import COCOEvaluator, inference_on_dataset
#register your data
import os
from point_rend.config import add_pointrend_config #most important
# from detectron2.utils.logger import setup_logger
# setup_logger()
from detectron2 import model_zoo
from detectron2.config import get_cfg
from detectron2.data.datasets import register_coco_instances
from detectron2.engine import DefaultTrainer
import fiftyone as fo
import fiftyone.zoo as foz
dataset = foz.load_zoo_dataset("quickstart")
session = fo.launch_app(dataset)
"""Note that if you are running this code in a script,
you must include session.wait() to block execution until you close the App."""
session.wait()
list_annotations = [247, 1202, 268, 1206, 262, 1232, 242, 1227, 247, 1202]
res = [(f , q) for f, q in zip(list_annotations[::2], list_annotations[1::2])]
print(res)
#output
#[(247, 1202), (268, 1206), (262, 1232), (242, 1227), (247, 1202)]
print(cfg.dump())
with open("/code/detectron2/detectron2/output/custom_mask_rcnn_X_101_32x8d_FPN_3x_my_dataset.yaml", "w") as f:
f.write(cfg.dump())
# -*- coding: utf-8 -*-
import os
from detectron2.utils.logger import setup_logger
setup_logger()
from detectron2 import model_zoo
from detectron2.config import get_cfg
from detectron2.data.datasets import register_coco_instances
from detectron2.engine import DefaultTrainer
#import the COCO Evaluator to use the COCO Metrics
from detectron2.config import get_cfg
from detectron2.engine import DefaultPredictor
from detectron2.data import build_detection_test_loader
from detectron2.data.datasets import register_coco_instances
from detectron2.evaluation import COCOEvaluator, inference_on_dataset
#register your data
register_coco_instances("my_dataset_train", {}, "/code/detectron2/detectron2/instances_train2017.json", "/code/detectron2/detectron2/train2017")
register_coco_instances("my_dataset_val", {}, "/code/detectron2/detectron2/instances_val2017.json", "/code/detectron2/detectron2/val2017")
docker run -p 9976:9976 --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=1,2 -it -v /detectron2_detection/:/code/ --name=detectron2_container detectron2:v0
wget http://images.cocodataset.org/val2017/000000439715.jpg -O input.jpg
python3 demo/demo.py \
#--config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \
#--input input.jpg --output outputs/ \
#--opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl