subject_matter / app.py
pleonova's picture
Update app.py
a0702e3 verified
raw
history blame
380 Bytes
from fastapi import FastAPI
from transformers import pipeline
app = FastAPI()
classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
@app.post("/predict")
async def predict(data: dict):
labels = ["Mathematics", "Language Arts", "Social Studies", "Science"]
result = classifier(data["text"], labels)
return {"label": result["labels"][0]}