Skip to content

Commit 5f07192

Browse files
authored
Merge pull request #15 from XBastille/testing_2
added NVIDIA CUDA Docker support
2 parents ccbfaeb + 26bcb59 commit 5f07192

24 files changed

Lines changed: 1620 additions & 474 deletions

Dockerfile.gpu

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04
2+
3+
ENV PYTHONDONTWRITEBYTECODE 1
4+
ENV PYTHONUNBUFFERED 1
5+
ENV NVIDIA_VISIBLE_DEVICES all
6+
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
7+
8+
WORKDIR /app
9+
10+
ARG NODE_MAJOR=22
11+
12+
RUN apt-get update \
13+
&& apt-get install -y --no-install-recommends \
14+
ca-certificates \
15+
curl \
16+
gnupg \
17+
build-essential \
18+
libglib2.0-0 \
19+
libsm6 \
20+
libxext6 \
21+
libxrender1 \
22+
libgomp1 \
23+
libfontconfig1 \
24+
ffmpeg \
25+
libgl1-mesa-glx \
26+
libgl1-mesa-dri \
27+
libglu1-mesa \
28+
python3 \
29+
python3-pip \
30+
python3-dev \
31+
&& mkdir -p /etc/apt/keyrings \
32+
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
33+
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
34+
&& apt-get update \
35+
&& apt-get install -y --no-install-recommends nodejs \
36+
&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
37+
&& apt-get clean \
38+
&& useradd --create-home python \
39+
&& chown python:python -R /app
40+
41+
USER python
42+
43+
COPY --chown=python:python requirements*.txt ./
44+
45+
RUN pip3 install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
46+
47+
RUN pip3 install --no-cache-dir -r requirements.txt
48+
49+
ENV DEBUG="false" \
50+
PYTHONUNBUFFERED="true" \
51+
PYTHONDONTWRITEBYTECODE="1" \
52+
PATH="${PATH}:/home/python/.local/bin" \
53+
USER="python" \
54+
QT_QPA_PLATFORM="offscreen" \
55+
CUDA_VISIBLE_DEVICES="0" \
56+
HF_HOME="/app/.cache/huggingface" \
57+
WEB_CONCURRENCY="2"
58+
59+
COPY --chown=python:python package.json tailwind.config.js ./
60+
61+
RUN npm install
62+
63+
COPY --chown=python:python . .
64+
65+
RUN mkdir -p static/css staticfiles media tmp
66+
67+
RUN chmod +x ./startup.sh
68+
69+
RUN chmod +x ./download-models.sh
70+
RUN ./download-models.sh
71+
72+
ARG HF_TOKEN
73+
ENV HF_TOKEN=${HF_TOKEN}
74+
RUN if [ -n "$HF_TOKEN" ]; then \
75+
echo "Downloading HuggingFace models..."; \
76+
python3 download-hf-models.py; \
77+
else \
78+
echo "HF_TOKEN not provided - models will be downloaded at runtime"; \
79+
fi
80+
81+
RUN npm run build
82+
83+
RUN python3 manage.py collectstatic --no-input --verbosity 2
84+
85+
RUN python3 manage.py migrate
86+
87+
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
88+
CMD curl -f http://localhost:8000/admin/login/ || exit 1
89+
90+
EXPOSE 8000
91+
92+
CMD ["./startup.sh"]

ai_image_editor/models/apply_fill.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,3 @@ def apply_fill(
8383

8484
result = result.resize(original_size)
8585
result.save(img_filled_p)
86-
87-
88-
if __name__ == "__main__":
89-
input_img = "test.jpg"
90-
img_stem = Path(input_img).stem
91-
masks_dir = f"./results/{img_stem}"
92-
text_prompt = "front view of a blond woman with a warm smile"
93-
94-
apply_fill(
95-
input_img=input_img,
96-
masks_dir=masks_dir,
97-
text_prompt=text_prompt,
98-
controlnet_scale=0.9,
99-
guidance_scale=3.5,
100-
num_inference_steps=40,
101-
negative_prompt="Low quality, Blurry, Overexposed, Underexposed, Grainy, Pixelated, Low resolution, Distorted, Over-saturated, Washed out",
102-
seed=None,
103-
)

ai_image_editor/models/transformer_flux.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,4 +520,4 @@ def custom_forward(*inputs):
520520
if not return_dict:
521521
return (output,)
522522

523-
return Transformer2DModelOutput(sample=output)
523+
return Transformer2DModelOutput(sample=output)

ai_image_editor/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,4 @@ def process_image(request):
148148

149149
return JsonResponse(
150150
{"status": "success", "result": f"data:image/png;base64,{img_str}"}
151-
)
151+
)

build-gpu.bat

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@echo off
2+
3+
echo Building DeepFX Studio GPU Docker image...
4+
5+
if "%HF_TOKEN%"=="" (
6+
echo Warning: HF_TOKEN environment variable not set!
7+
echo Gated models (SD 3.5, FLUX) will be downloaded at runtime.
8+
echo To pre-download models, set HF_TOKEN first:
9+
echo set HF_TOKEN=your_huggingface_token
10+
echo.
11+
12+
docker build -f Dockerfile.gpu -t deepfx-studio-gpu .
13+
) else (
14+
echo HF_TOKEN found - will pre-download gated models
15+
16+
docker build -f Dockerfile.gpu --build-arg HF_TOKEN=%HF_TOKEN% -t deepfx-studio-gpu .
17+
)
18+
19+
echo.
20+
echoBuild completed!
21+
echoTo run: docker run --gpus all -p 8000:8000 deepfx-studio-gpu
22+
pause

build-gpu.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "Building DeepFX Studio GPU Docker image..."
6+
7+
if [ -z "$HF_TOKEN" ]; then
8+
echo "Warning: HF_TOKEN environment variable not set!"
9+
echo " Gated models (SD 3.5, FLUX) will be downloaded at runtime."
10+
echo " To pre-download models, set HF_TOKEN first:"
11+
echo " export HF_TOKEN=your_huggingface_token"
12+
echo ""
13+
14+
docker build -f Dockerfile.gpu -t deepfx-studio-gpu .
15+
else
16+
echo "HF_TOKEN found - will pre-download gated models"
17+
18+
docker build -f Dockerfile.gpu \
19+
--build-arg HF_TOKEN="$HF_TOKEN" \
20+
-t deepfx-studio-gpu .
21+
fi
22+
23+
echo ""
24+
echo "Build completed!"
25+
echo "To run: docker run --gpus all -p 8000:8000 deepfx-studio-gpu"

core/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
Core Django app for DeepFX Studio dependency management
3+
"""

core/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

core/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class CoreConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'core'

0 commit comments

Comments
 (0)