File size: 370 Bytes
dc71762
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastapi import FastAPI
from pydantic import BaseModel
from joblib import load
import pickle

app = FastAPI()

with open('gs_clf.pickle', 'rb') as f:
    spam_classifier = pickle.load(f)

class Item(BaseModel):
    text: str

@app.post("/classify/")
async def classify_text(item: Item):
    return {"result": spam_classifier.predict([item.text])[0]}