Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Base image with CUDA 12.4
FROM nvidia/cuda:12.4.1-base-ubuntu22.04

# Update and Install packages
RUN apt-get update -y && apt-get install -y \
python3-pip \
python3-dev \
ffmpeg \
libsm6 \
libxext6

# Define environment variables for UID and GID
ENV PUID=${PUID:-1000}
ENV PGID=${PGID:-1000}

# Create a group with the specified GID
RUN groupadd -g "${PGID}" appuser
# Create a user with the specified UID and GID
RUN useradd -m -s /bin/sh -u "${PUID}" -g "${PGID}" appuser

WORKDIR /app

# Install main application dependencies
COPY ./requirements.cuda.txt ./requirements.cuda.txt
RUN pip install --no-cache-dir -r ./requirements.cuda.txt

# Install Torch, Torchvision, and Torchaudio for CUDA 12.4
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

RUN chown -R appuser:appuser /app

# delete redundant requirements.cuda.txt
RUN rm ./requirements.cuda.txt

#Run application as non-root
USER appuser

# Copy diffusers image fill application code
COPY . ./diffusers-image-fill

EXPOSE 7860

ENV GRADIO_SERVER_NAME="0.0.0.0"

WORKDIR /app/diffusers-image-fill

# Run diffusers-image-fill Python application
CMD ["python3", "./app.py"]
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
## Diffusers Image Fill

Remove or replace objects from any image, on your local computer.

This is a very simple gradio app that lets you remove or replace objects from ANY image.

**Note**: that there are pretty good object removal AIs already.

The difference is that it's based on Diffusion and actually uses inpainting to do the removal.

Additional features I added to the original app.

Added features:

1. No square crop
2. Use Full resolution (default: 1024x1024)
3. Replace objects (via custom prompt)
4. Custom steps/guidance scale

This app uses *RealVisXL V5.0 Lightning* (based on Stable Diffusion XL) for inpainting.

This is already great. But just imagine the same thing, but using Flux. Imagine being able to:

1. Replace TEXT into images,
2. Render hi-def output
3. No hand issues

One cool thing about this app is, you can keep retrying until you find the one that you like.

Works on ALL OS (Mac, Windows, Linux)

Available on pinokio and Docker

### Install using Docker

Open `docker-compose.yml` and delete everything below the comment line if you don't have a `traefik` reverse proxy.

Then simply run:
```
docker compose up -d --build --force-recreate --remove-orphans
```

Check logs:
```
docker logs -f diffusers-image-fill
```
38 changes: 38 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
services:
diffusers-image-fill:
build:
context: .
dockerfile: Dockerfile
image: diffusers-image-fill
container_name: diffusers-image-fill
environment:
- PUID=${PUID:-1000}
- PGID=${PGID:-1000}
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ./:/app/diffusers-image-fill
stop_signal: SIGKILL
tty: true
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
restart: unless-stopped
#Delete below if you're not using a reverse proxy
networks:
- traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.diffusers-image-fill.rule=Host(`image-fill.local.example.com`)"
- "traefik.http.routers.diffusers-image-fill.entrypoints=https"
- "traefik.http.routers.diffusers-image-fill.tls=true"
- "traefik.http.routers.diffusers-image-fill.tls.certresolver=cloudflare"
- "traefik.http.services.diffusers-image-fill.loadbalancer.server.port=7860"
- "traefik.http.routers.diffusers-image-fill.middlewares=default-headers@file"
networks:
traefik:
external: true
11 changes: 11 additions & 0 deletions requirements.cuda.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
spaces
gradio==4.42.0
gradio-imageslider
numpy==1.26.4
transformers
accelerate
diffusers
fastapi<0.113.0
opencv-python
devicetorch
pillow