Keira commited on
Commit ·
12bd11c
1
Parent(s): 3821e56
Add application file
Browse files- .DS_Store +0 -0
- Dockerfile +5 -11
- app.py +10 -2
- requirements.txt +3 -1
.DS_Store
CHANGED
|
Binary files a/.DS_Store and b/.DS_Store differ
|
|
|
Dockerfile
CHANGED
|
@@ -1,16 +1,10 @@
|
|
| 1 |
-
|
| 2 |
-
# you will also find guides on how best to write your Dockerfile
|
| 3 |
-
|
| 4 |
-
FROM python:3.9
|
| 5 |
-
|
| 6 |
-
RUN useradd -m -u 1000 user
|
| 7 |
-
USER user
|
| 8 |
-
ENV PATH="/home/user/.local/bin:$PATH"
|
| 9 |
|
| 10 |
WORKDIR /app
|
| 11 |
|
| 12 |
-
COPY
|
| 13 |
-
RUN pip install -
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
COPY --chown=user . /app
|
| 16 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
FROM python:3.10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
COPY requirements.txt .
|
| 6 |
+
RUN pip install -r requirements.txt
|
| 7 |
+
|
| 8 |
+
COPY . .
|
| 9 |
|
|
|
|
| 10 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
CHANGED
|
@@ -1,7 +1,15 @@
|
|
| 1 |
from fastapi import FastAPI
|
|
|
|
| 2 |
|
| 3 |
app = FastAPI()
|
| 4 |
|
|
|
|
|
|
|
| 5 |
@app.get("/")
|
| 6 |
-
def
|
| 7 |
-
return {"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
app = FastAPI()
|
| 5 |
|
| 6 |
+
classifier = pipeline("sentiment-analysis")
|
| 7 |
+
|
| 8 |
@app.get("/")
|
| 9 |
+
def home():
|
| 10 |
+
return {"message": "API is running"}
|
| 11 |
+
|
| 12 |
+
@app.get("/predict")
|
| 13 |
+
def predict(text: str):
|
| 14 |
+
result = classifier(text)
|
| 15 |
+
return result
|
requirements.txt
CHANGED
|
@@ -1,2 +1,4 @@
|
|
| 1 |
fastapi
|
| 2 |
-
uvicorn
|
|
|
|
|
|
|
|
|
| 1 |
fastapi
|
| 2 |
+
uvicorn
|
| 3 |
+
transformers
|
| 4 |
+
torch
|