File size: 996 Bytes
bf40459 a39633b ecf78b7 bf40459 a39633b 2b4def6 8c2dd5d a39633b 8c2dd5d 4a75742 a39633b 8c2dd5d 4a75742 8c2dd5d a62447c 8c2dd5d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
---
license: apache-2.0
tags:
- Bounding box detection
- PyTorch
---
This repository contains code that you can use to train or load [Faster R-CNN](https://arxiv.org/pdf/1504.08083.pdf) 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)
``` |