Created
February 25, 2020 07:58
-
-
Save davamix/ae8818ebba64458a9e19b481ad453b65 to your computer and use it in GitHub Desktop.
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
appuser@0350938812fa:/tmp/src$ python3 test.py | |
Failed to load OpenCL runtime | |
## PROPOSALS ## | |
Instances(num_instances=2000, image_height=573, image_width=687, fields=[proposal_boxes, objectness_logits]) | |
## FIELDS ## | |
{'proposal_boxes': Boxes(tensor([[286.9893, 37.3016, 687.0000, 536.0049], | |
[161.1793, 62.7907, 687.0000, 573.0000], | |
[256.4062, 144.6316, 687.0000, 573.0000], | |
..., | |
[464.0695, 306.8295, 477.6617, 346.7988], | |
[288.0411, 148.8542, 340.1854, 304.7098], | |
[472.3310, 230.6041, 499.8146, 254.9045]], device='cuda:0')), 'objectness_logits': tensor([ 6.8021, 6.4931, 6.4103, ..., -2.8630, -2.8631, -2.8631], | |
device='cuda:0')} |
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
import os | |
import cv2 | |
from detectron2.config import get_cfg | |
from detectron2 import model_zoo | |
from detectron2.engine import DefaultPredictor | |
from detectron2.utils.visualizer import Visualizer, ColorMode | |
from detectron2.data import MetadataCatalog | |
classes = ["Blacky", "Niche"] | |
cfg = get_cfg() | |
cfg.merge_from_file(model_zoo.get_config_file("COCO-Detection/rpn_R_50_C4_1x.yaml")) | |
cfg.DATASETS.TEST = ("cats_val") | |
cfg.MODEL.WEIGHTS = os.path.join(cfg.OUTPUT_DIR, "model_final_deepseek.pth") | |
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 2 | |
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.7 | |
predictor = DefaultPredictor(cfg) | |
# Predict image | |
def test_image(image_path): | |
image = cv2.imread(image_path) | |
outputs = predictor(image) | |
print("## PROPOSALS ##") | |
print(outputs['proposals']) | |
print("## FIELDS ##") | |
print(outputs['proposals'].get_fields()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment