NVIDIA / ai-assisted-annotation-client

Client side integration example source code and libraries for AI-Assisted Annotation SDK
Other
307 stars 64 forks source link

Create session with multiple input files #93

Closed che85 closed 1 year ago

che85 commented 2 years ago

Is there a way to create a session by uploading multiple image files?

As of now, it seems that there is only one "image" uploaded.

SachidanandAlle commented 2 years ago

The API supports accepting multiple image files as part of session.. another option is to zip and upload.. in the session send the param to uncompress

che85 commented 2 years ago

Is there an example of that somewhere?

SachidanandAlle commented 2 years ago

Try http://127.0.0.1:5000/docs (where aiaa server is running) You might find information about uncompress flag..

For multiple files in PUT.. you may not use openapi docs.. it might not support.. you can use curl.. https://github.com/SachidanandAlle/Viewers/blob/master/extensions/nvidia-aiaa/src/AIAAService/AIAAUtils.js#L27-L31

The above is sample js code for sending multiple files in the put request for session.. used in OHIF AIAA plugin

che85 commented 2 years ago

@SachidanandAlle Thanks for the reply.

I was able to create a session for multiple files, but when loading the data I am getting errors:

[2021-11-04 15:56:42] [DEBUG] (aiaa.actions.inference_engine._pre_processing:115) - Run Pre Processing
[2021-11-04 15:56:42] [DEBUG] (aiaa.actions.inference_engine._pre_processing:116) - Pre-Processing Input Keys: dict_keys(['image', 'image_path', 'params', 'transform_meta'])
[2021-11-04 15:56:42] [INFO] (aiaa.inference.inference_utils.run_transforms:69) - PRE - Run Transforms
[2021-11-04 15:56:42] [INFO] (aiaa.inference.inference_utils.run_transforms:70) - PRE - Input Keys: dict_keys(['image', 'image_path', 'params', 'transform_meta'])
[2021-11-04 15:56:42] [DEBUG] (aiaa.inference.inference_utils.dump_data:42) - **************************** DATA ********************************************
[2021-11-04 15:56:42] [DEBUG] (aiaa.inference.inference_utils.dump_data:45) - Data key: image = /tmp/tmpfx5jr7um
[2021-11-04 15:56:42] [DEBUG] (aiaa.inference.inference_utils.dump_data:45) - Data key: image_path = /tmp/tmp7la94_ae
[2021-11-04 15:56:42] [DEBUG] (aiaa.inference.inference_utils.dump_data:45) - Data key: params = {}
[2021-11-04 15:56:42] [DEBUG] (aiaa.inference.inference_utils.dump_data:45) - Data key: transform_meta = {}
[2021-11-04 15:56:42] [DEBUG] (aiaa.inference.inference_utils.dump_data:55) - ******************************************************************************
WARNING: In /work/ITK-source/ITK/Modules/IO/GDCM/src/itkGDCMSeriesFileNames.cxx, line 102
GDCMSeriesFileNames (0x7f37d57fdc30): No Series were found

[2021-11-04 15:56:42] [ERROR] (aiaa.www.api.api_v1.handle_error:35) - no DICOMs in: /tmp/tmpfx5jr7um.
[2021-11-04 15:56:42] Traceback (most recent call last):
[2021-11-04 15:56:42]   File "/opt/conda/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
[2021-11-04 15:56:42]     rv = self.dispatch_request()
[2021-11-04 15:56:42]   File "/opt/conda/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
[2021-11-04 15:56:42]     return self.view_functions[rule.endpoint](**req.view_args)
[2021-11-04 15:56:42]   File "www/api/api_v1.py", line 368, in api_v1_inference
[2021-11-04 15:56:42]   File "www/api/api_v1.py", line 255, in run_inference
[2021-11-04 15:56:42]   File "www/api/api_v1.py", line 168, in run_infer
[2021-11-04 15:56:42]   File "actions/inference_engine.py", line 73, in run
[2021-11-04 15:56:42]   File "actions/inference_engine.py", line 119, in _pre_processing
[2021-11-04 15:56:42]   File "inference/inference_utils.py", line 81, in run_transforms
[2021-11-04 15:56:42]   File "/opt/monai/monai/transforms/io/dictionary.py", line 105, in __call__
[2021-11-04 15:56:42]     data = self._loader(d[key], reader)
[2021-11-04 15:56:42]   File "/opt/monai/monai/transforms/io/array.py", line 154, in __call__
[2021-11-04 15:56:42]     img = reader.read(filename)
[2021-11-04 15:56:42]   File "/opt/monai/monai/data/image_reader.py", line 189, in read
[2021-11-04 15:56:42]     raise FileNotFoundError(f"no DICOMs in: {name}.")
[2021-11-04 15:56:42] FileNotFoundError: no DICOMs in: /tmp/tmpfx5jr7um.

The code I used for uploading looks as follows:

selector = '/session/?expiry=' + str(0)
status, response, _ = client_api.AIAAUtils.http_multipart('PUT', client._server_url, selector, fields={}, files={"image": "input_mid_systolic_frame.nii.gz", "label": "input_annulus_label.nii.gz"})

The uploaded directory looks as follows:

image

The meta.info file:

{"name": "355a10a4-3d8b-11ec-8013-0242ac130003", "path": "/workspace/sessions/355a10a4-3d8b-11ec-8013-0242ac130003", "image": "/workspace/sessions/355a10a4-3d8b-11ec-8013-0242ac130003/tmpfx5jr7um", "image_original": "/workspace/sessions/355a10a4-3d8b-11ec-8013-0242ac130003/tmpfx5jr7um", "meta": {}, "create_ts": 1636042864, "last_access_ts": 1636042864, "expiry": 3600}

I assume that the LoadImage is trying to load the "image" directory as a DICOM series which actually shouldn't happen.

Is there any resource where I can read more about this?

Also, I would assume that the meta.info would have the dictionary information as used in the PUT request. In other words, the folder holding the image and label is not assigned the "image" flag which is why it's trying to load it as a DICOM series.

Am I missing something?

SachidanandAlle commented 2 years ago

you can add your own LoadImage transform.. which will load the image+label the way you want..

SachidanandAlle commented 2 years ago

Have you tried using https://github.com/Project-MONAI/MONAILabel/ ? Probably you can write/customize a lot based on your use-cases

che85 commented 2 years ago

@SachidanandAlle Thank you. I can try MONAILabel.

Would you recommend using MONAILabel over AIAA?

Wasn't there a plan to fuse AIAA into MONAILabel?

SachidanandAlle commented 1 year ago

Closing this issue.. please use MONAILabel instead.. feel free to raise any issue or start discussion over MONAILabel repo

diazandr3s commented 1 year ago

MONAI Label repo: https://github.com/Project-MONAI/MONAILabel