File size: 523 Bytes
b8aa51a
3ca686a
 
b8aa51a
 
3ca686a
 
 
b8aa51a
 
 
 
 
3ca686a
b8aa51a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastapi import HTTPException, File, UploadFile
from .preprocess import preprocess_image
from .inferencer import classify_image


async def Classify_Image_router(file: UploadFile = File(...)):
    try:
        image_array = preprocess_image(file)
        try:
            result = classify_image(image_array)
            return result
        except:
            raise HTTPException(status_code=423, detail="something went wrong")

    except Exception as e:
        raise HTTPException(status_code=413, detail=str(e))