Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI, File, UploadFile | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from PIL import Image | |
| import io | |
| from app.models.animal_vision import predict_animal | |
| from app.models.plant_vision import predict_plant | |
| app = FastAPI( | |
| title = 'BIONEXUS Image Intelligence API', | |
| version = '1.0.0' | |
| ) | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins = ['*'], | |
| allow_credentials = True, | |
| allow_methods = ['*'], | |
| allow_headers = ['*'], | |
| ) | |
| async def animal_predict(file: UploadFile = File(...)): | |
| image = Image.open(io.BytesIO(await file.read())).convert('RGB') | |
| result = predict_animal(image) | |
| return result | |
| async def plant_predict(file: UploadFile = File(...)): | |
| image = Image.open(io.BytesIO(await file.read())).convert('RGB') | |
| result = predict_plant(image) | |
| return result |