Spaces:
Runtime error
Runtime error
File size: 855 Bytes
864175f 0b4f018 864175f 0b4f018 864175f 0b4f018 864175f 0b4f018 864175f 0b4f018 864175f 210a419 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
from fastapi import FastAPI, Request
import uvicorn
import re
from model.zero_shot_classification import ZeroShotClassifier
from tracemalloc import start
app = FastAPI()
@app.get('/predict')
async def predict(request:Request):
try:
start()
response = await request.json()
data = response['data']
if data == None or data == "":
return {
'status':False,
'result':'Data is empty'
}
result = await ZeroShotClassifier().Predict(text=data)
return {
'status':True,
'result':result
}
except Exception as err:
return {
'status':False,
'result':
"Something went wrong, {}".format(err)
}
if __name__ == '__main__':
uvicorn.run(app) |