update
Browse files- Dockerfile +10 -3
- app/app.py +5 -1
- app/requirements.txt +1 -0
Dockerfile
CHANGED
|
@@ -1,9 +1,16 @@
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
|
|
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
EXPOSE 7860
|
|
|
|
|
|
|
| 9 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
| 3 |
+
# Cài các thư viện cần thiết
|
| 4 |
+
RUN pip install --no-cache-dir fastapi uvicorn transformers pydantic
|
| 5 |
|
| 6 |
+
# Copy mã nguồn
|
| 7 |
+
COPY app.py /app/app.py
|
| 8 |
|
| 9 |
+
# Làm việc trong thư mục app
|
| 10 |
+
WORKDIR /app
|
| 11 |
+
|
| 12 |
+
# Expose cổng đúng (quan trọng với HF Space)
|
| 13 |
EXPOSE 7860
|
| 14 |
+
|
| 15 |
+
# Chạy FastAPI
|
| 16 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app/app.py
CHANGED
|
@@ -16,4 +16,8 @@ class InputText(BaseModel):
|
|
| 16 |
@app.post("/predict")
|
| 17 |
def predict(data: InputText):
|
| 18 |
result = classifier(data.text)
|
| 19 |
-
return {"result": result}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
@app.post("/predict")
|
| 17 |
def predict(data: InputText):
|
| 18 |
result = classifier(data.text)
|
| 19 |
+
return {"result": result}
|
| 20 |
+
|
| 21 |
+
@app.get("/")
|
| 22 |
+
def root():
|
| 23 |
+
return {"message": "✅ FastAPI đang chạy tại /predict"}
|
app/requirements.txt
CHANGED
|
@@ -2,3 +2,4 @@ fastapi
|
|
| 2 |
transformers
|
| 3 |
torch
|
| 4 |
uvicorn
|
|
|
|
|
|
| 2 |
transformers
|
| 3 |
torch
|
| 4 |
uvicorn
|
| 5 |
+
pydantic
|