| from fastapi import FastAPI, HTTPException, Depends, Request | |
| import models | |
| from transformers import pipeline | |
| import uvicorn | |
| app = FastAPI() | |
| 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) |