File size: 916 Bytes
5999b43
fe5ce44
5999b43
5e59807
5999b43
 
5e59807
fe5ce44
5e59807
5999b43
 
 
fe5ce44
5e59807
5999b43
fe5ce44
 
5e59807
5999b43
fe5ce44
5e59807
5999b43
20f4351
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# THE FINAL, CORRECT BLUEPRINT.

FROM python:3.10-slim

# Install curl, which we need to download the model during the build.
RUN apt-get update && apt-get install -y curl

WORKDIR /code

# THE ARCHITECTURAL FIX: We download the HEAVY AI model ONCE, during the build.
# It will be baked into the application. It will never be downloaded at runtime.
# This solves all startup timeout and "Starting..." errors forever.
RUN curl -L "https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth" -o /tmp/sam_model.pth

# Install the lightweight Python libraries.
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir -r /code/requirements.txt

# Copy our API code into the main directory. No sub-folders.
COPY ./main.py /code/main.py

# The simple, reliable startup command. It starts ONE worker, fixing the memory crash.
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]