Bounding box detection
PyTorch
frcnn / README.md
huu-ontocord's picture
Update README.md
a62447c verified
metadata
license: apache-2.0
tags:
  - Bounding box detection
  - PyTorch

This repository contains code that you can use to train or load Faster R-CNN models in half mode easily.

Below is an example of how to load pretrained weights in half mode.

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),  box_segmentation_model, image_preprocessor, max_detections=max_detections)