Ziad Meligy
Fixing some issues with Docker Image
f603a8d
Raw
History Blame Contribute Delete
1.8 kB
from fastapi import FastAPI, UploadFile, File, Form
from fastapi.responses import JSONResponse
from maira2Service import generate_report
from readimageService import read_image
app = FastAPI()
@app.post("/generate/frontal")
async def generate_frontal_report(frontal: UploadFile = File(...)):
try:
frontal_img = read_image(frontal)
report = generate_report(frontal_image=frontal_img)
return JSONResponse(content={"report": report})
except Exception as e:
return JSONResponse(status_code=500, content={"error": str(e)})
@app.post("/generate/lateral")
async def generate_lateral_report(
frontal: UploadFile = File(...),
lateral: UploadFile = File(...),
indication: str = Form(...),
technique: str = Form(...),
comparison: str = Form(...)
):
try:
frontal_img = read_image(frontal)
lateral_img = read_image(lateral)
report = generate_report(
frontal_image=frontal_img,
lateral_image=lateral_img,
indication=indication,
technique=technique,
comparison=comparison
)
return JSONResponse(content={"report": report})
except Exception as e:
return JSONResponse(status_code=500, content={"error": str(e)})
@app.post("/generate/lateral/both")
async def generate_lateral_both_report(
frontal: UploadFile = File(...),
lateral: UploadFile = File(...),
):
try:
frontal_img = read_image(frontal)
lateral_img = read_image(lateral)
report = generate_report(
frontal_image=frontal_img,
lateral_image=lateral_img,
)
return JSONResponse(content={"report": report})
except Exception as e:
return JSONResponse(status_code=500, content={"error": str(e)})