jina-ai / executor-image-torch-object-detection-segmenter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  1. 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
  2. Use jinahub-executor-image-torch-object-detection-segmenter in your code

    from jina import Flow
    from jinahub.segmenter.torch_object_detection_segmenter import TorchObjectDetectionSegmenter
    
    f = Flow().add(uses=TorchObjectDetectionSegmenter)

🐳 Via Docker

  1. 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 .
  2. Use executor-image-torch-object-detection-segmenter in your codes

    from 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.

πŸ”οΈ Reference

About


Languages

Language:Python 96.6%Language:Shell 2.2%Language:Dockerfile 1.2%