Spaces:
Sleeping
Sleeping
Download Dockerfile from jer6/sentiment-api: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/jer6/sentiment-api/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/jer6/sentiment-api/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/jer6/sentiment-api/resolve/main/Dockerfile
1.12 kB
| FROM python:3.11-slim | |
| # Dépendances système minimales | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| TRANSFORMERS_CACHE=/models \ | |
| HF_HOME=/models \ | |
| PYTHONPATH=/app | |
| WORKDIR /app | |
| COPY requirements.txt ./ | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Pré-téléchargement des modèles pour éviter le cold start | |
| RUN python - <<'PY' | |
| from transformers import pipeline | |
| from transformers import MarianMTModel, MarianTokenizer | |
| print('Downloading XLM-R sentiment...') | |
| pipeline('sentiment-analysis', model='cardiffnlp/twitter-xlm-roberta-base-sentiment') | |
| print('Downloading FinBERT...') | |
| pipeline('sentiment-analysis', model='yiyanghkust/finbert-tone') | |
| print('Downloading Marian FR-EN...') | |
| MarianTokenizer.from_pretrained('Helsinki-NLP/opus-mt-fr-en') | |
| MarianMTModel.from_pretrained('Helsinki-NLP/opus-mt-fr-en') | |
| print('All models cached.') | |
| PY | |
| COPY app ./app | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"] |