Closed
Description
I have a web api in which I want to analyze dicom images. It is defined using FastAPI
The method that gets dicom is defined like this:
@analyze_my_dicom.post("/analyze_my_dicom")
async def analyze_my_dicom(dicom: UploadFile = File(...)):
filename = join(
dirname(realpath(__file__)), "dicoms", dicom.filename
)
try:
with open(filename, "wb") as buffer:
shutil.copyfileobj(dicom.file, buffer)
transform = LoadImaged(keys="image")
data = {"image": filename}
image = transform(data)["image"]
...
Is there a possibility to use LoadInaged
directly on UploadFile
, so I don't have to save the object to the memory but can work with it directly?