|
from fastapi import FastAPI |
|
from pydantic import BaseModel |
|
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline |
|
|
|
|
|
tokenizer = AutoTokenizer.from_pretrained("paulagarciaserrano/roberta-depression-detection") |
|
model = AutoModelForSequenceClassification.from_pretrained("paulagarciaserrano/roberta-depression-detection") |
|
depression_pipe = pipeline("text-classification", model=model, tokenizer=tokenizer) |
|
|
|
|
|
class DepressionInput(BaseModel): |
|
text: str |
|
|
|
|
|
app = FastAPI() |
|
|
|
|
|
@app.post("/depression_detection") |
|
async def detect_depression(item: DepressionInput): |
|
result = depression_pipe(item.text) |
|
return result |
|
|
|
|