AIIA / ml-service /app.py
RosiYo's picture
feat[bert]: FastAPI interface
df16f8c
raw
history blame
462 Bytes
# app.py
from fastapi import FastAPI, APIRouter
import uvicorn
from classifier import Classifier
import nlp
import logging
logging.basicConfig(level = logging.INFO)
# Create the FastAPI instance
app = FastAPI()
classifier = Classifier()
@app.post("/predict")
def predict(data: dict):
try:
input_text = data["text"]
res = nlp.sentiment_analysis(classifier, input_text)
return res
except Exception as e:
logging.error("Something went wrong")