Spaces:
Sleeping
Sleeping
Muhammad Usman Nazir commited on
Commit ·
37b9169
1
Parent(s): 318a4d2
fix: update Dockerfile to use CUDA base image and install Python dependencies, adjust segmentation model in configuration
Browse files- Dockerfile +12 -7
- app.py +1 -1
- visualizer.hf.toml +2 -2
Dockerfile
CHANGED
|
@@ -1,20 +1,26 @@
|
|
| 1 |
-
FROM
|
| 2 |
|
| 3 |
# Set environment variables
|
| 4 |
ENV PYTHONUNBUFFERED=1 \
|
| 5 |
PYTHONDONTWRITEBYTECODE=1 \
|
| 6 |
HF_HOME=/home/user/.cache/huggingface \
|
| 7 |
VISUALIZER_CONFIG=visualizer.hf.toml \
|
| 8 |
-
HOME=/home/user
|
|
|
|
| 9 |
|
| 10 |
-
# Install
|
| 11 |
RUN apt-get update && \
|
| 12 |
apt-get install -y --no-install-recommends \
|
|
|
|
|
|
|
|
|
|
| 13 |
git \
|
| 14 |
ffmpeg \
|
| 15 |
libglib2.0-0 \
|
| 16 |
libgomp1 \
|
| 17 |
build-essential && \
|
|
|
|
|
|
|
| 18 |
rm -rf /var/lib/apt/lists/*
|
| 19 |
|
| 20 |
# Set up a new user named "user" with UID 1000 for Hugging Face permissions
|
|
@@ -23,12 +29,11 @@ RUN useradd -m -u 1000 user
|
|
| 23 |
WORKDIR /app
|
| 24 |
|
| 25 |
# Copy requirements files first
|
| 26 |
-
COPY requirements-base.txt ./
|
| 27 |
|
| 28 |
-
# Install
|
| 29 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 30 |
-
pip install --no-cache-dir
|
| 31 |
-
pip install --no-cache-dir -r requirements-base.txt
|
| 32 |
|
| 33 |
# Copy the rest of the application files
|
| 34 |
COPY --chown=user:1000 . .
|
|
|
|
| 1 |
+
FROM nvidia/cuda:12.6.3-runtime-ubuntu22.04
|
| 2 |
|
| 3 |
# Set environment variables
|
| 4 |
ENV PYTHONUNBUFFERED=1 \
|
| 5 |
PYTHONDONTWRITEBYTECODE=1 \
|
| 6 |
HF_HOME=/home/user/.cache/huggingface \
|
| 7 |
VISUALIZER_CONFIG=visualizer.hf.toml \
|
| 8 |
+
HOME=/home/user \
|
| 9 |
+
DEBIAN_FRONTEND=noninteractive
|
| 10 |
|
| 11 |
+
# Install Python and system dependencies
|
| 12 |
RUN apt-get update && \
|
| 13 |
apt-get install -y --no-install-recommends \
|
| 14 |
+
python3.10 \
|
| 15 |
+
python3.10-venv \
|
| 16 |
+
python3-pip \
|
| 17 |
git \
|
| 18 |
ffmpeg \
|
| 19 |
libglib2.0-0 \
|
| 20 |
libgomp1 \
|
| 21 |
build-essential && \
|
| 22 |
+
ln -sf /usr/bin/python3.10 /usr/bin/python3 && \
|
| 23 |
+
ln -sf /usr/bin/python3 /usr/bin/python && \
|
| 24 |
rm -rf /var/lib/apt/lists/*
|
| 25 |
|
| 26 |
# Set up a new user named "user" with UID 1000 for Hugging Face permissions
|
|
|
|
| 29 |
WORKDIR /app
|
| 30 |
|
| 31 |
# Copy requirements files first
|
| 32 |
+
COPY requirements-base.txt requirements-gpu-cu126.txt ./
|
| 33 |
|
| 34 |
+
# Install CUDA PyTorch/Torchvision first, then other base requirements
|
| 35 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 36 |
+
pip install --no-cache-dir -r requirements-gpu-cu126.txt
|
|
|
|
| 37 |
|
| 38 |
# Copy the rest of the application files
|
| 39 |
COPY --chown=user:1000 . .
|
app.py
CHANGED
|
@@ -945,7 +945,7 @@ def build_segmentation_bundle(contents: bytes):
|
|
| 945 |
|
| 946 |
t0 = time.perf_counter()
|
| 947 |
img = Image.open(io.BytesIO(contents)).convert("RGB")
|
| 948 |
-
MAX_DIM =
|
| 949 |
if max(img.width, img.height) > MAX_DIM:
|
| 950 |
scale = MAX_DIM / max(img.width, img.height)
|
| 951 |
img = img.resize((int(img.width * scale), int(img.height * scale)), Image.LANCZOS)
|
|
|
|
| 945 |
|
| 946 |
t0 = time.perf_counter()
|
| 947 |
img = Image.open(io.BytesIO(contents)).convert("RGB")
|
| 948 |
+
MAX_DIM = 1280
|
| 949 |
if max(img.width, img.height) > MAX_DIM:
|
| 950 |
scale = MAX_DIM / max(img.width, img.height)
|
| 951 |
img = img.resize((int(img.width * scale), int(img.height * scale)), Image.LANCZOS)
|
visualizer.hf.toml
CHANGED
|
@@ -3,8 +3,8 @@
|
|
| 3 |
# VISUALIZER_CONFIG=visualizer.hf.toml uvicorn app:app --host 0.0.0.0 --port 7860
|
| 4 |
|
| 5 |
[models]
|
| 6 |
-
segmentation_model = "
|
| 7 |
-
|
| 8 |
depth_model_name = "Intel/dpt-large"
|
| 9 |
intrinsic_model_version = "v2"
|
| 10 |
|
|
|
|
| 3 |
# VISUALIZER_CONFIG=visualizer.hf.toml uvicorn app:app --host 0.0.0.0 --port 7860
|
| 4 |
|
| 5 |
[models]
|
| 6 |
+
segmentation_model = "oneformer"
|
| 7 |
+
oneformer_model_name = "shi-labs/oneformer_ade20k_swin_large"
|
| 8 |
depth_model_name = "Intel/dpt-large"
|
| 9 |
intrinsic_model_version = "v2"
|
| 10 |
|