drrobot9's picture
Initial commit
86e9c13 verified
raw
history blame contribute delete
892 Bytes
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 = ['*'],
)
@app.post('/animal/predict')
async def animal_predict(file: UploadFile = File(...)):
image = Image.open(io.BytesIO(await file.read())).convert('RGB')
result = predict_animal(image)
return result
@app.post('/plant/predict')
async def plant_predict(file: UploadFile = File(...)):
image = Image.open(io.BytesIO(await file.read())).convert('RGB')
result = predict_plant(image)
return result