Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segment_volume fails with past models containing NumpyToTensor key #829

Closed
mariehbourget opened this issue Jun 23, 2021 · 0 comments · Fixed by #830
Closed

segment_volume fails with past models containing NumpyToTensor key #829

mariehbourget opened this issue Jun 23, 2021 · 0 comments · Fixed by #830
Assignees
Labels
bug category: fixes an error in the code priority:medium testing Test related change

Comments

@mariehbourget
Copy link
Member

Issue description

The function segment_volume fails after the merge of #818 when segmenting with a model containing the "NumpyToTensor": {} field in transformation parameters. (tagging @dyt811 and @cakester so they are aware)

I found this #758 (comment) on the opened PR #758 with what seems to be a fix for this. If that is the case, I think the fix should be done in a dedicated PR as soon as possible.

Current behavior

Config file of models trained prior to the merge of #818 contains the "NumpyToTensor": {} field. This config file is used by the function segment_volume for segmentation.

The segmentation fails with the following error when undoing transforms:

Traceback (most recent call last):
  File "/home/mhbourget/venv-ivadomed-38c/bin/ivadomed", line 11, in <module>
    load_entry_point('ivadomed', 'console_scripts', 'ivadomed')()
  File "/home/mhbourget/ivadomed/ivadomed/main.py", line 560, in run_main
    run_command(context=context,
  File "/home/mhbourget/ivadomed/ivadomed/main.py", line 340, in run_command
    run_segment_command(context, model_params)
  File "/home/mhbourget/ivadomed/ivadomed/main.py", line 274, in run_segment_command
    pred_list, target_list = imed_inference.segment_volume(path_model,
  File "/home/mhbourget/ivadomed/ivadomed/inference.py", line 407, in segment_volume
    pred_list, target_list, last_sample_bool, weight_matrix, volume, image = reconstruct_3d_object(
  File "/home/mhbourget/ivadomed/ivadomed/inference.py", line 483, in reconstruct_3d_object
    image_reconstruction(batch, preds, undo_transforms, i_slice, image, weight_matrix)
  File "/home/mhbourget/ivadomed/ivadomed/inference.py", line 609, in image_reconstruction
    pred_undo, metadata = undo_transforms(image, batch['gt_metadata'][smp_idx], data_type='gt')
  File "/home/mhbourget/ivadomed/ivadomed/transforms.py", line 184, in __call__
    sample, metadata = tr.undo_transform(sample, metadata)
  File "/home/mhbourget/ivadomed/ivadomed/transforms.py", line 210, in undo_transform
    return list(sample.numpy()), metadata
AttributeError: 'list' object has no attribute 'numpy'

Note: a newly trained model without the NumpyToTensor key does not produced this error.

Expected behavior

  • "NumpyToTensor": {} field from old config files should be ignored somehow to ensure retrocompatibility and avoid this error.
  • functional_tests/test_segment_volume.py should test for this. This is not the case right now and tests are passing because they don't use old config files.
@mariehbourget mariehbourget added the bug category: fixes an error in the code label Jun 23, 2021
@dyt811 dyt811 self-assigned this Jun 23, 2021
@dyt811 dyt811 added testing Test related change priority:medium labels Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug category: fixes an error in the code priority:medium testing Test related change
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants