File size: 485 Bytes
cf6e4e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from fastapi import FastAPI, HTTPException, Depends, Request
import models
from transformers import pipeline
import uvicorn


app = FastAPI()

@app.get('/detect_lang')
async def detect_lang(text: models.Text):
    try:
        pipe(text.text)
    except Exception as e:
        raise HTTPException(status_code=400, detail=f'{e}')

if __name__ == "__main__":
    pipe = pipeline("text-classification", model="rifkat/uz_kr_lang-detection")
    uvicorn.run(app, host="0.0.0.0", port=7860)