Spaces:
Sleeping
Sleeping
| # 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=["*"], | |
| ) | |
| async def root(): | |
| return {"message": "Welcome to the medicinal plants image detection API!"} | |
| 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 | |