Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
-
from transformers import pipeline
|
| 3 |
-
|
| 4 |
-
app = FastAPI()
|
| 5 |
-
classifier = pipeline("text-classification")
|
| 6 |
-
|
| 7 |
-
@app.get("/")
|
| 8 |
-
def root():
|
| 9 |
-
return {"status": "
|
| 10 |
-
|
| 11 |
-
@app.get("/classify")
|
| 12 |
-
def classify(text: str):
|
| 13 |
-
result = classifier(text)
|
| 14 |
-
return {"label": result[0][
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
app = FastAPI()
|
| 5 |
+
classifier = pipeline("text-classification")
|
| 6 |
+
|
| 7 |
+
@app.get("/")
|
| 8 |
+
def root():
|
| 9 |
+
return {"status": "ready"}
|
| 10 |
+
|
| 11 |
+
@app.get("/classify")
|
| 12 |
+
def classify(text: str):
|
| 13 |
+
result = classifier(text)
|
| 14 |
+
return {"label": result[0]["label"], "score": result[0]["score"]}
|