from transformers import pipeline from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class TextInput(BaseModel): text: str classifier = pipeline("text-classification", model="./") @app.post("/predict") async def predict(input_data: TextInput): result = classifier(input_data.text) return result