Replicate crash with Selfie Segmentation
docker-compose build
docker-compose run --rm mp-test python -m mp_test.mp_selfie_segmentation
version: '3' | |
services: | |
mp-test: | |
image: "local/mp-test:develop" | |
build: | |
context: . |
FROM python:3.8-buster | |
RUN apt-get update \ | |
&& apt-get install -y --no-install-recommends \ | |
libgl1 \ | |
&& rm -rf /var/lib/apt/lists/* | |
COPY requirements.build.txt ./ | |
RUN pip install --disable-pip-version-check --user -r requirements.build.txt | |
COPY requirements.txt ./ | |
RUN pip install --disable-pip-version-check --user -r requirements.txt | |
COPY mp_test ./mp_test |
from time import sleep | |
import numpy as np | |
import mediapipe as mp | |
from tqdm import tqdm | |
mp_drawing = mp.solutions.drawing_utils | |
mp_selfie_segmentation = mp.solutions.selfie_segmentation | |
image_shape = (480, 640, 3) | |
np.random.seed(42) | |
print('Press Ctrl+C to exit') | |
try: | |
with mp_selfie_segmentation.SelfieSegmentation( | |
model_selection=1 | |
) as selfie_segmentation: | |
with tqdm() as pbar: | |
while True: | |
image = (np.random.random_sample(image_shape) * 255).astype('uint8') | |
result = selfie_segmentation.process(image) | |
result.segmentation_mask | |
sleep(0.01) | |
pbar.update(1) | |
except KeyboardInterrupt: | |
print('exiting') |
pip==21.1.3 | |
wheel==0.36.2 |
opencv-python==4.5.2.54 | |
mediapipe==0.8.6 | |
tqdm==4.61.1 |