Microservice detecting clothes on given image using:
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
Model architecture and other details can be found in the following repository https://github.com/pawelbeza/ClothesDetectorModel
docker build -t clothes-detector .
docker run --rm -p 8080:8080 --name clothes-detector clothes-detector
docker run --gpus all --rm -p 8080:8080 --name clothes-detector clothes-detector
nvidia-container-toolkit package is needed to run container with GPU support
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()