Skip to content

Instantly share code, notes, and snippets.

@benperiton
Last active February 25, 2024 19:19
Show Gist options
  • Save benperiton/2d37ea18377a80f9b9768522d08a4253 to your computer and use it in GitHub Desktop.
Save benperiton/2d37ea18377a80f9b9768522d08a4253 to your computer and use it in GitHub Desktop.
backgroundremover test
version: '3.3'
services:
backgroundremover:
build:
context: ./
dockerfile: Dockerfile
args:
- UID=1000
- GID=1001
container_name: "backgroundremover"
user: "1000:1001"
restart: "no"
volumes:
- './images:/app:rw'
working_dir: /app
FROM python:3.6-slim
ARG UID
ARG GID
RUN groupadd -g "${GID}" app \
&& useradd --create-home --no-log-init -u "${UID}" -g "${GID}" app
RUN apt-get update && \
apt-get -y install python3-pip && \
apt-get -y install ffmpeg imagemagick
USER app
RUN pip install --default-timeout=1000 torch torchvision backgroundremover
WORKDIR /app
ENTRYPOINT ["tail"]
CMD ["-f","/dev/null"]
docker exec -it backgroundremover /bin/bash
/home/app/.local/bin/backgroundremover -i input.jpeg -m u2net_human_seg -o output.jpeg
convert output.jpeg -colorspace Gray -trim final.png
@eevmanu
Copy link

eevmanu commented May 8, 2023

hi @benperiton , I'm just curious, is there any reason why in use.txt line 3 you use .jpeg as file format for the output instead of directly using .png and prefer to use convert to pass .jpeg into .png? is it related to resolution? or file size?

I know there is a difference incoming form convert call, because of -colorspace Gray -trim, but not sure if have input file as .jpeg is required before applying those transformations (via command options).

@benperiton
Copy link
Author

No reason at all, I was just playing around with it and that happened to be what I typed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment