Spaces:
Sleeping
Sleeping
File size: 737 Bytes
798b314 7fefcad 798b314 44a9798 7fefcad 798b314 7fefcad 798b314 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# app.py
from fastapi import FastAPI, File, UploadFile
from fastapi.middleware.cors import CORSMiddleware
from predict import read_image, transformacao
app = FastAPI()
# Add CORS middleware to allow requests from any origin (for development)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
async def root():
return {"message": "Welcome to the medicinal plants image detection API!"}
@app.post("/uploadfile/")
async def create_upload_file(file: UploadFile = File(...)):
contents = await file.read()
# read image
imagem = read_image(contents)
# transform and prediction
prediction = transformacao(imagem)
return prediction
|