Moved to https://github.com/jina-ai/executors/tree/main/jinahub/segmenters/TorchObjectDetectionSegmenter
β¨ TorchObjectDetectionSegmenter
TorchObjectDetectionSegmenter is a class that supports object detection and bounding box extraction using PyTorch with Faster R-CNN and Mask R-CNN models.
Table of Contents
π± Prerequisites
To install the dependencies locally run
pip install .
pip install -r tests/requirements.txt
To verify the installation works:
pytest tests
π Usages
π Via JinaHub
using docker images
Use the prebuilt images from JinaHub in your python codes,
from jina import Flow
f = Flow().add(uses='jinahub+docker://TorchObjectDetectionSegmenter')
or in the .yml
config.
jtype: Flow
pods:
- name: encoder
uses: 'jinahub+docker://TorchObjectDetectionSegmenter'
using source codes
Use the source codes from JinaHub in your python codes,
from jina import Flow
f = Flow().add(uses='jinahub://TorchObjectDetectionSegmenter')
or in the .yml
config.
jtype: Flow
pods:
- name: encoder
uses: 'jinahub://TorchObjectDetectionSegmenter'
π¦οΈ Via Pypi
-
Install the
jinahub-executor-image-torch-object-detection-segmenter
package.pip install git+https://github.com/jina-ai/executor-image-torch-object-detection-segmenter.git
-
Use
jinahub-executor-image-torch-object-detection-segmenter
in your codefrom jina import Flow from jinahub.segmenter.torch_object_detection_segmenter import TorchObjectDetectionSegmenter f = Flow().add(uses=TorchObjectDetectionSegmenter)
π³ Via Docker
-
Clone the repo and build the docker image
git clone https://github.com/jina-ai/EXECUTOR_REPO_NAME.git cd EXECUTOR_REPO_NAME docker build -t executor-image-torch-object-detection-segmenter .
-
Use
executor-image-torch-object-detection-segmenter
in your codesfrom jina import Flow f = Flow().add(uses='docker://executor-image-torch-object-detection-segmenter:latest')
ποΈ Example
from jina import Flow, Document
f = Flow().add(uses='jinahub+docker://TorchObjectDetectionSegmenter')
with f:
resp = f.post(on='foo', inputs=Document(), return_results=True)
print(f'{resp}')
Inputs
Document
whose blob
stores the image to be detected with values between 0-1 and has color channel at the last axis.
Returns
Document
with chunks
that contain the original image in blob
, bounding box coordinates of objects detected in location
, and image label key value pair in tags
.