Spaces:
Sleeping
Sleeping
| # ----------- λ² μ΄μ€ μ΄λ―Έμ§ ----------- | |
| FROM python:3.10-slim | |
| # ----------- μμ λλ ν 리 ----------- | |
| WORKDIR /app | |
| # ----------- μμ€ν ν¨ν€μ§ μ€μΉ ----------- | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| cmake \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # ----------- μμ‘΄μ± μ€μΉ ----------- | |
| # requirements λ¨Όμ λ³΅μ¬ β μΊμ νμ© κ°λ₯ | |
| COPY requirements.txt /app/requirements.txt | |
| # PyTorch CPU λ²μ μ€μΉ (GPU νμ μμ) | |
| RUN pip install --no-cache-dir torch==2.0.1+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html \ | |
| && pip install --no-cache-dir -r /app/requirements.txt | |
| # ----------- μ½λ λ³΅μ¬ ----------- | |
| # μμ‘΄μ± μ€μΉ ν μ½λ λ³΅μ¬ β requirements λ³κ²½ μλ ν μΊμ μ¬μ¬μ© κ°λ₯ | |
| COPY . /app/ | |
| # ----------- λͺ¨λΈ λ€μ΄λ‘λ ----------- | |
| # transformers λͺ¨λΈ λ€μ΄λ‘λ ν μ΄λ―Έμ§μ ν¬ν¨ | |
| RUN python -c "from transformers import AutoTokenizer, AutoModel; \ | |
| models = { \ | |
| 'emotion': ('tae898/emoberta-base-ko', './models/emotion-classification-model'), \ | |
| 'fallback': ('skt/ko-gpt-trinity-1.2B-v0.5', './models/fallback-npc-model'), \ | |
| 'embedder': ('sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2', './models/sentence-embedder') \ | |
| }; \ | |
| import os; \ | |
| os.makedirs('./models/emotion-classification-model', exist_ok=True); \ | |
| os.makedirs('./models/fallback-npc-model', exist_ok=True); \ | |
| os.makedirs('./models/sentence-embedder', exist_ok=True); \ | |
| for key, (name, path) in models.items(): \ | |
| AutoModel.from_pretrained(name, cache_dir=path); \ | |
| AutoTokenizer.from_pretrained(name, cache_dir=path)" | |
| # ----------- νκ²½ λ³μ μ€μ ----------- | |
| ENV EMOTION_MODEL_DIR=/app/models/emotion-classification-model | |
| ENV FALLBACK_MODEL_DIR=/app/models/fallback-npc-model | |
| ENV EMBEDDER_MODEL_DIR=/app/models/sentence-embedder | |
| # ----------- ν¬νΈ μ€μ ----------- | |
| EXPOSE 8000 | |
| # ----------- μ€ν λͺ λ Ή ----------- | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "${PORT:-8000}"] | |