Spaces:
Running
Running
Commit
·
5bb4004
1
Parent(s):
fa605c6
Update cache dir
Browse files- Dockerfile +5 -0
- app.py +4 -3
Dockerfile
CHANGED
@@ -7,6 +7,11 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
7 |
# Create working directory (and authorised token)
|
8 |
WORKDIR /app
|
9 |
|
|
|
|
|
|
|
|
|
|
|
10 |
# Install SSL root certs and system deps required by pymongo + DNS
|
11 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
12 |
ca-certificates curl dnsutils gcc openssl && \
|
|
|
7 |
# Create working directory (and authorised token)
|
8 |
WORKDIR /app
|
9 |
|
10 |
+
# Add to Dockerfile
|
11 |
+
ENV TRANSFORMERS_CACHE=/app/model_cache
|
12 |
+
ENV HF_HOME=/app/.cache/huggingface
|
13 |
+
ENV SENTENCE_TRANSFORMERS_HOME=/app/.cache/huggingface/sentence-transformers
|
14 |
+
|
15 |
# Install SSL root certs and system deps required by pymongo + DNS
|
16 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
17 |
ca-certificates curl dnsutils gcc openssl && \
|
app.py
CHANGED
@@ -56,9 +56,10 @@ model = None
|
|
56 |
@app.on_event("startup")
|
57 |
async def load_models():
|
58 |
global processor, model
|
59 |
-
|
60 |
-
|
61 |
-
model.
|
|
|
62 |
|
63 |
|
64 |
############################################
|
|
|
56 |
@app.on_event("startup")
|
57 |
async def load_models():
|
58 |
global processor, model
|
59 |
+
cache_path = Path("model_cache") # local writable path inside Hugging Face Space
|
60 |
+
processor = WhisperProcessor.from_pretrained(ASR_MODEL_ID, cache_dir=cache_path)
|
61 |
+
model = WhisperForConditionalGeneration.from_pretrained(ASR_MODEL_ID, cache_dir=cache_path)
|
62 |
+
model.to("cpu")
|
63 |
|
64 |
|
65 |
############################################
|