Spaces:
Sleeping
Sleeping
from fastapi import FastAPI | |
from fastapi.responses import JSONResponse | |
from pydantic import BaseModel | |
from transformers import pipeline | |
import uvicorn | |
app = FastAPI() | |
class Payload(BaseModel): | |
text: str | |
async def classify_text(text): | |
pipe = pipeline("text-classification", | |
model="SamLowe/roberta-base-go_emotions") | |
return pipe(text) | |
async def classify(payload: Payload): | |
result = await classify_text(payload.text) | |
return JSONResponse({"data": result}) | |