File size: 1,742 Bytes
ad37be7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# you will also find guides on how best to write your Dockerfile

FROM python:3.10-slim

WORKDIR /app

# Cache all HF model downloads in a fixed location baked into the image
ENV HF_HOME=/app/.cache/huggingface
ENV HF_HUB_CACHE=/app/.cache/huggingface/hub

RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    git \
    libxrender1 \
    libxext6 \
    libx11-6 \
    libsm6 \
    libfreetype6 \
    libpng-dev \
    libcairo2 \
    && rm -rf /var/lib/apt/lists/*

COPY ./requirements.txt requirements.txt
RUN pip install --upgrade pip setuptools wheel \
    && pip install -r requirements.txt

# Pre-download all models at build time so they're on disk at runtime
RUN python -c "\
from huggingface_hub import snapshot_download, hf_hub_download; \
models = { \
    'cn': 'SalZa2004/Cetane_Number_Predictor', \
    'ysi': 'SalZa2004/YSI_Predictor', \
    'bp': 'SalZa2004/Boiling_Point_Predictor', \
    'density': 'SalZa2004/Density_Predictor', \
    'lhv': 'SalZa2004/LHV_Predictor', \
    'dv': 'SalZa2004/Dynamic_Viscosity_Predictor', \
    'dcn': 'SalZa2004/MolPool_GNN_model', \
}; \
[snapshot_download(repo_id=v, repo_type='model') for v in models.values()]; \
hf_hub_download(repo_id='mrashid26/Biodiesel_CN_Predictor', filename='src/biodiesel_cn_model.pkl', repo_type='space'); \
hf_hub_download(repo_id='mrashid26/Biodiesel_CN_Predictor', filename='src/ood_stats.pkl', repo_type='space'); \
print('All models downloaded and cached.')"

COPY . /app

CMD ["gunicorn", "-b", "0.0.0.0:7860", "--workers", "1", "--timeout", "0", "--max-requests", "200", "--max-requests-jitter", "50", "app:app"]