AIIA / ml-service /app.py
RosiYo's picture
feat[bert]: FastAPI interface
b59078e
raw
history blame contribute delete
472 Bytes
# app.py
from fastapi import FastAPI
from classifier import Classifier
import nlp
import logging
logging.basicConfig(level = logging.INFO)
# Create the FastAPI instance
app = FastAPI(docs_url='/', redoc_url='/new_redoc')
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")