CadenShokat commited on
Commit
4ffc264
·
verified ·
1 Parent(s): 93f8930

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -2
Dockerfile CHANGED
@@ -1,7 +1,7 @@
1
  FROM python:3.11-slim
2
 
3
- ENV HF_HOME=/data/hfcache \
4
- TRANSFORMERS_CACHE=/data/hfcache \
5
  PYTHONDONTWRITEBYTECODE=1 \
6
  PYTHONUNBUFFERED=1
7
 
@@ -11,6 +11,25 @@ WORKDIR /app
11
  COPY requirements.txt .
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  COPY app.py .
15
 
16
  EXPOSE 7860
 
1
  FROM python:3.11-slim
2
 
3
+ ENV HF_HOME=/app/hf_cache \
4
+ HF_HUB_ENABLE_HF_TRANSFER=1 \
5
  PYTHONDONTWRITEBYTECODE=1 \
6
  PYTHONUNBUFFERED=1
7
 
 
11
  COPY requirements.txt .
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
14
+ RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
15
+
16
+ RUN python - <<'PY'
17
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
18
+ PRIMARY="cardiffnlp/twitter-roberta-base-sentiment-latest"
19
+ FALLBACK="distilbert-base-uncased-finetuned-sst-2-english"
20
+ print("Pre-caching:", PRIMARY)
21
+ try:
22
+ AutoTokenizer.from_pretrained(PRIMARY)
23
+ AutoModelForSequenceClassification.from_pretrained(PRIMARY)
24
+ print("Primary cached.")
25
+ except Exception as e:
26
+ print("Primary cache failed:", e)
27
+ print("Caching fallback:", FALLBACK)
28
+ AutoTokenizer.from_pretrained(FALLBACK)
29
+ AutoModelForSequenceClassification.from_pretrained(FALLBACK)
30
+ print("Fallback cached.")
31
+ PY
32
+
33
  COPY app.py .
34
 
35
  EXPOSE 7860