Spaces:
Sleeping
Sleeping
Download features/image_classifier/controller.py from can-org/Testing-AI-Contain: direct link, hf CLI and curl.
- Browser
- Download file 523 Bytes
-
https://huggingface.co/spaces/can-org/Testing-AI-Contain/resolve/refs%2Fpr%2F1/features/image_classifier/controller.py
- Command line
-
hf download hf://spaces/can-org/Testing-AI-Contain@refs/pr/1/features/image_classifier/controller.py
-
curl -L -o controller.py https://huggingface.co/spaces/can-org/Testing-AI-Contain/resolve/refs%2Fpr%2F1/features/image_classifier/controller.py
523 Bytes
| 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)) | |