antonioguj / bronchinet

Airway segmentation from chest CTs using deep Convolutional Neural Networks
MIT License
62 stars 26 forks source link

Unable to predict from pre-trained PyTorch Model #3

Closed id-b3 closed 4 years ago

id-b3 commented 4 years ago

When launching the launch_pipeline_predictions.py script, the script fails with an error when loading up the saved model. Here is the terminal output:

(emc3) ivand@ID-Magic-Crate:~/Desktop/Ground_Truth_Segmentation$ python Code/scripts_airway_segmentation/launch_pipeline_predictions.py BaseData/Models/Model_DLST_LUVAR_28.pt BaseData/Results
Print input arguments...
'input_model_file' = BaseData/Models/Model_DLST_LUVAR_28.pt
'output_basedir' = BaseData/Results
'basedir' = /home/ivand/Desktop/Ground_Truth_Segmentation/
'post_thresholds_values' = [0.5]
'list_type_metrics_result' = ['DiceCoefficient', 'AirwayCompleteness', 'AirwayVolumeLeakage', 'AirwayCentrelineLeakage', 'AirwayCentrelineDistanceFalsePositiveError', 'AirwayCentrelineDistanceFalseNegativeError']
'testing_datadir' = TestingData/
'is_connected_masks' = False
'is_backward_compat' = False
****************************************************************************************************
<<< Launch: python3 /home/ivand/Desktop/Ground_Truth_Segmentation/Code/scripts_experiments/predict_model.py BaseData/Models/Model_DLST_LUVAR_28.pt --basedir /home/ivand/Desktop/Ground_Truth_Segmentation --in_config_file BaseData/Models/configparams.txt --name_output_predictions_relpath BaseData/Results/PosteriorsWorkData --name_output_reference_keys_file BaseData/Results/referenceKeys_posteriors.npy --testing_datadir TestingData/ --is_backward_compat False >>>
****************************************************************************************************

Set up experiments with parameters from file: 'BaseData/Models/configparams.txt'
Print input arguments...
'basedir' = /home/ivand/Desktop/Ground_Truth_Segmentation
'in_config_file' = BaseData/Models/configparams.txt
'is_backward_compat' = False
'is_mask_region_interest' = True
'is_save_featmaps_layers' = False
'is_valid_convolutions' = True
'list_type_metrics' = []
'name_input_reference_keys_file' = referenceKeys_procimages.npy
'name_output_predictions_relpath' = BaseData/Results/PosteriorsWorkData
'name_output_reference_keys_file' = BaseData/Results/referenceKeys_posteriors.npy
'name_save_feats_model_layer' = convU12
'preds_model_file' = BaseData/Models/Model_DLST_LUVAR_28.pt
'prop_overlap_sliding_window' = (0.5, 0.5, 0.5)
'size_in_images' = (252, 252, 252)
'testing_datadir' = TestingData/
'type_loss' = DiceCoefficient
'use_sliding_window_images' = True
'use_transform_elasticdeform_images' = False
'use_transform_rigid_images' = False

Load Saved model...
------------------------------
Compute Predictions from file: 'BaseData/Models/Model_DLST_LUVAR_28.pt'...
Load full model (model weights and description, optimizer, loss and metrics) to restart model...
Traceback (most recent call last):
  File "/home/ivand/Desktop/Ground_Truth_Segmentation/Code/scripts_experiments/predict_model.py", line 190, in <module>
    main(args)
  File "/home/ivand/Desktop/Ground_Truth_Segmentation/Code/scripts_experiments/predict_model.py", line 56, in main
    model_trainer.load_model_full(args.preds_model_file)
  File "/home/ivand/Desktop/Ground_Truth_Segmentation/Code/models/pytorch/modeltrainer.py", line 71, in load_model_full
    type_network = model_full['network_desc'][0]
KeyError: 'network_desc'

I'm not sure what to do with this issue @AntonioGUJ maybe you can help

antonioguj commented 4 years ago

It's due to backward compatibility issues with the newer version of the code and models previously stored. You can specify a flag in the script you launched as 'is_backward_compat=True'

id-b3 commented 4 years ago

Thanks! It fixes that issue.