Spaces:
Runtime error
Runtime error
import logging | |
import uvicorn | |
from fastapi import FastAPI | |
from pydantic import BaseModel | |
from transformers import pipeline | |
logging.basicConfig( | |
format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s', | |
level=logging.DEBUG, | |
datefmt='%Y-%m-%d %H:%M:%S' | |
) | |
classifier = pipeline("zero-shot-classification", model="models/classificator", use_fast=False) | |
app = FastAPI() | |
class RequestData(BaseModel): | |
multiLabel: bool | |
sequence: str | |
labels: list[str] | |
class ResponseData(BaseModel): | |
sequence: str | |
labels: list[str] | |
scores: list[float] | |
async def classify_text(data: RequestData): | |
result = classifier(data.sequence, data.labels, multi_label=data.multiLabel) | |
logging.info(result) | |
return result | |
def ping(): | |
return "pong" | |
if __name__ == "__main__": | |
uvicorn.run(app, host="127.0.0.1", port=8000) | |