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

Issue exporting trained nnUNet model #2184

Open
skim2257 opened this issue May 15, 2024 · 1 comment
Open

Issue exporting trained nnUNet model #2184

skim2257 opened this issue May 15, 2024 · 1 comment
Assignees

Comments

@skim2257
Copy link

Unable to export the model zipfile to share the model.

I ran:

nnUNetv2_export_model_to_zip 
-o ../model.zip 
-c 3d_fullres 
-d 001 
-f 0 
-chk checkpoint_best.pth

This was the output:

Configuration 3d_fullres
Exporting fold_0
Traceback (most recent call last):
  File "miniconda3/envs/nnunet/bin/nnUNetv2_export_model_to_zip", line 33, in <module>
    sys.exit(load_entry_point('nnunetv2', 'console_scripts', 'nnUNetv2_export_model_to_zip')())
  File "nnUNetv2/nnunetv2/model_sharing/entry_points.py", line 59, in export_pretrained_model_entry
    export_pretrained_model(dataset_name_or_id=args.d, output_file=args.o, configurations=args.c, trainer=args.tr,
  File "nnUNetv2/nnunetv2/model_sharing/model_export.py", line 62, in export_pretrained_model
    zipf.write(source_file, os.path.relpath(source_file, nnUNet_results))
  File "miniconda3/envs/nnunet/lib/python3.10/zipfile.py", line 1737, in write
    zinfo = ZipInfo.from_file(filename, arcname,
  File "miniconda3/envs/nnunet/lib/python3.10/zipfile.py", line 502, in from_file
    st = os.stat(filename)
FileNotFoundError: [Errno 2] No such file or directory 'Dataset001_DATASET/nnUNetTrainer__nnUNetPlans__3d_fullres/fold_0/validation/summary.json'

Please excuse the sanitized paths in the output log. 
My `fold_0` folder looks like this:

-rw-r--r-- 1 sejinkim bhklab 236M May 18 2023 checkpoint_best.pth
-rw-r--r-- 1 sejinkim bhklab 236M May 18 2023 checkpoint_latest.pth
-rw-r--r-- 1 sejinkim bhklab 17K May 17 2023 debug.json
-rw-r--r-- 1 sejinkim bhklab 628K May 18 2023 progress.png
-rw-r--r-- 1 sejinkim bhklab 58K May 18 2023 training_log_2023_5_17_15_29_35.txt


I'm also happy to produce the Zipfile myself, if you can direct me to what `install_model_from_zip_file` expects. 

Thanks,
Sejin
@constantinulrich
Copy link
Member

constantinulrich commented May 15, 2024

Hi, this function wants to zip the summary.json file as well which will be generated after the training and validation.
2 Possibilities: You could just run the missing validation (--val at the end of your training command) or just un comment the part here of the function.

Edid: you would need to adapt the function also in some other parts, should still be easy to do.
Best
Constantin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants