kreshuklab / plant-seg

A tool for cell instance aware segmentation in densely packed 3D volumetric images
https://kreshuklab.github.io/plant-seg/
MIT License
88 stars 31 forks source link

Error in using custom trained model #102

Closed sourabh-bhide closed 2 years ago

sourabh-bhide commented 2 years ago

Hi all, I have trained a model on my data using pytorch-3dunet as described in the readme file. The output was three files

  1. best_checkpoint.pytorch
  2. last_checkpoint.pytorch
  3. logs All fine till this point. I tried to copy this model_folder to ~./plantseg_models folder and then use config.yaml file to get network inference. I used name of my model_folder in the 'model_name' filed in the config file. I am getting the following error :

Traceback (most recent call last): File "/projects/dan1/people/hcr770/envs/plant-seg/bin/plantseg", line 10, in sys.exit(main()) File "/projects/dan1/people/hcr770/envs/plant-seg/lib/python3.7/site-packages/plantseg/run_plantseg.py", line 28, in main raw2seg(config) File "/projects/dan1/people/hcr770/envs/plant-seg/lib/python3.7/site-packages/plantseg/pipeline/raw2seg.py", line 54, in raw2seg config = config_validation(config) File "/projects/dan1/people/hcr770/envs/plant-seg/lib/python3.7/site-packages/plantseg/pipeline/config_validation.py", line 264, in config_validation config = recursive_config_check(config, template) File "/projects/dan1/people/hcr770/envs/plant-seg/lib/python3.7/site-packages/plantseg/pipeline/config_validation.py", line 197, in recursive_config_check config[key] = recursive_config_check(config[key], template[key]) File "/projects/dan1/people/hcr770/envs/plant-seg/lib/python3.7/site-packages/plantseg/pipeline/config_validation.py", line 193, in recursive_config_check config[key] = value(key, config[key]) File "/projects/dan1/people/hcr770/envs/plant-seg/lib/python3.7/site-packages/plantseg/pipeline/config_validation.py", line 153, in call out = check(key, out, self.fallback) File "/projects/dan1/people/hcr770/envs/plant-seg/lib/python3.7/site-packages/plantseg/pipeline/config_validation.py", line 107, in model_exist _error_message(f"value must be one of {_list_models}", key, value, fallback) File "/projects/dan1/people/hcr770/envs/plant-seg/lib/python3.7/site-packages/plantseg/pipeline/config_validation.py", line 21, in _error_message raise RuntimeError(_error) RuntimeError: key: model_name has got value: model_explants, but value must be one of ['generic_confocal_3d_unet', 'generic_light_sheet_3d_unet', 'confocal_unet_bce_dice_ds1x', 'confocal_unet_bce_dice_ds2x', 'confocal_unet_bce_dice_ds3x, , 'confocal_2D_unet_bce_dice_ds1x', 'confocal_2D_unet_bce_dice_ds2x', 'confocal_2D_unet_bce_dice_ds3x', 'confocal_unet_bce_dice_nuclei_stain_ds1x', 'lightsheet_unet_bce_dice_ds1x', 'lightsheet_unet_bce_dice_nuclei_ds1x', 'lightsheet_unet_bce_dice_ds2x', 'lightsheet_unet_bce_dice_ds3x', 'confocal_PNAS_2d', 'confocal_PNAS_3d']

Could you please suggest me a solution ? I can always use pytorch-3dunet to get boundary predictions and then use plantseg for segmentation; but I was hoping to keep using plantseg framework for doing both, predictions and segmentation.

best, Sourabh

lorenzocerrone commented 2 years ago

Hi @sourabh-bhide,

Sorry for the inconvenience, the instruction are wrong. There is a step missing, the model has to be registered by adding it to the ~./plantseg_models/custom_zoo.yaml. as an example:

model_name:
  description: ''optional description of the model"
  path: 'path to mode'
  resolution:
  - 1.0
  - 1.0
  - 1.0

Alternative, there is a add custom model in the gui that automatize this step.

Best,

Lorenzo

sourabh-bhide commented 2 years ago

Hi Lorenzo,

Fantastic. Thanks a lot for your comment.

best, Sourabh