metadata
license: apache-2.0
tags:
- Bounding box detection
- PyTorch
import numpy as np
from PIL import Image
from frcnn.visualizing_image import SingleImageViz
from frcnn.processing_image import Preprocess
from frcnn.modeling_frcnn import GeneralizedRCNN
from frcnn.utils import Config
max_detections = 36
frcnn_config = json.load(open("frcnn/config.jsonl"))
frcnn_config = Config(frcnn_config)
image_preprocessor= Preprocess(frcnn_config).half().cuda()
box_segmentation_model= GeneralizedRCNN.from_pretrained("unc-nlp/frcnn-vg-finetuned", frcnn_config).half().cuda()
img_url = 'image.png'
raw_image = Image.open(img_url).convert('RGB')
frcnn_output = decode_image(np.asarray(raw_image), frcnn, image_preprocessor, max_detections=max_detections)