api / main.py
Azzizz17's picture
Add application file
cf6e4e0
raw
history blame contribute delete
485 Bytes
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)