Spaces:
Runtime error
Runtime error
| from fastapi import FastAPI, UploadFile, File, Form | |
| from fastapi.responses import JSONResponse | |
| from maira2Service import generate_report | |
| from readimageService import read_image | |
| app = FastAPI() | |
| 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)}) | |
| 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)}) | |
| 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)}) | |