Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
app = FastAPI()
|
| 5 |
+
classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
|
| 6 |
+
|
| 7 |
+
@app.post("/predict")
|
| 8 |
+
async def predict(data: dict):
|
| 9 |
+
labels = ["Mathematics", "Language Arts", "Social Studies", "Science"]
|
| 10 |
+
result = classifier(data["text"], labels)
|
| 11 |
+
return {"label": result["labels"][0]}
|