Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Latest commit

 

History

History
50 lines (39 loc) · 1.65 KB

README.md

File metadata and controls

50 lines (39 loc) · 1.65 KB

Clothes detector

Microservice detecting clothes on given image using:

Download model

Download model from here and place it in models dir. Examplary download using gdown tool:
mkdir models && gdown -O ./models/model.pth --id google_drive_id

Quick note

Model architecture and other details can be found in the following repository https://github.com/pawelbeza/ClothesDetectorModel

Build

docker build -t clothes-detector .

Run container

using CPU

docker run --rm -p 8080:8080 --name clothes-detector clothes-detector

using GPU

docker run --gpus all --rm -p 8080:8080 --name clothes-detector clothes-detector

Quick note

nvidia-container-toolkit package is needed to run container with GPU support

Visualize predictions

import cv2
import requests

from PIL import Image
from detectron2.utils.visualizer import Visualizer
from detectron2.data import detection_utils as utils

URL = "IP:8080/detect"
files = {"image": open(filename, 'rb')}

res = requests.post(url=URL, files=files).json()

img = cv2.imread(filename)
img = utils.convert_image_to_rgb(img, 'BGR')

visualizer = Visualizer(img)
out = visualizer.overlay_instances(
    labels=res['classes'],
    boxes=res['boxes']
)

img_pil = Image.fromarray(out.get_image(), 'RGB')
img_pil.show()