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

Downloading pretrained weights (~140MB) ...Error #254

Open
wang-bingh opened this issue Oct 17, 2023 · 6 comments
Open

Downloading pretrained weights (~140MB) ...Error #254

wang-bingh opened this issue Oct 17, 2023 · 6 comments

Comments

@wang-bingh
Copy link

When I use ‘TractSeg -i hc1_DTI.nii.gz --raw_diffusion_input’ in Teminal to treat example DTI data, the following error continues to appear:

Loading weights from: /home/w/.tractseg/pretrained_weights_tract_segmentation_v3.npz
Downloading pretrained weights (~140MB) ...
Traceback (most recent call last):
File "/home/w/anaconda3/envs/torch/bin/TractSeg", line 7, in
exec(compile(f.read(), file, 'exec'))
File "/home/w/soft/TractSeg/bin/TractSeg", line 420, in
main()
File "/home/w/soft/TractSeg/bin/TractSeg", line 325, in main
seg = run_tractseg(data, args.output_type,
File "/home/w/soft/TractSeg/tractseg/python_api.py", line 154, in run_tractseg
utils.download_pretrained_weights(experiment_type=Config.EXPERIMENT_TYPE,
File "/home/w/soft/TractSeg/tractseg/libs/utils.py", line 170, in download_pretrained_weights
download_url(WEIGHTS_URL, weights_path)
File "/home/w/soft/TractSeg/tractseg/libs/utils.py", line 110, in download_url
raise e
File "/home/w/soft/TractSeg/tractseg/libs/utils.py", line 106, in download_url
r.raise_for_status()
File "/home/w/anaconda3/envs/torch/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://zenodo.org/record/3518348/files/best_weights_ep220.npz?download=1

However,the ‘url: https://zenodo.org/record/3518348/files/best_weights_ep220.npz?download=1’ can open and download at Firefox Web Browser.

How to solve this problem?

Thank you.

@wasserth
Copy link
Collaborator

Zenodo did a major update of their website and this also changed the way they accept download requests. I am working on a fix for this.

@wang-bingh
Copy link
Author

I also tried "wget https://zenodo.org/record/3518348/files/best_weights_ep220.npz?download=1" in the Terminal, it can also download the Date(best_weights_ep220.npz). Should I change some code in a certain file of TractSeg? Or we will just have to wait for Zenodo to give us an responsein the future.

@wasserth
Copy link
Collaborator

I fixed the problem and published a new version (v2.9) for pip.

@wang-bingh
Copy link
Author

wang-bingh commented Oct 17, 2023

Thank you so much for your helpful suggestion! I re-installed the new version (v2.9) just that and it seems to work fine !

@wang-bingh
Copy link
Author

wang-bingh commented Oct 17, 2023

Hi Prof Jakob,
I am getting an error when I use Tractseg to treat non-HCP data and I am not sure what it is due to, any suggestions are well appreciated!
Thank you!

The code for Tract Orientation Maps that I am running is:
TractSeg -i tractseg_output/peaks.nii.gz -o tractseg_output --output_type TOM --super_resolution

Here is the error text:
_/home/w/anaconda3/envs/torch_2023/bin/TractSeg:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
import('pkg_resources').require('TractSeg==2.9')
Loading weights from: /home/w/.tractseg/pretrained_weights_peak_regression_part1_v2.npz
100%|█████████████████████████████████████████| 144/144 [00:02<00:00, 63.55it/s]
Loading weights from: /home/w/.tractseg/pretrained_weights_peak_regression_part2_v2.npz
100%|████████████████████████████████████████| 144/144 [00:01<00:00, 129.27it/s]
Loading weights from: /home/w/.tractseg/pretrained_weights_peak_regression_part3_v2.npz
100%|████████████████████████████████████████| 144/144 [00:01<00:00, 130.46it/s]
Loading weights from: /home/w/.tractseg/pretrained_weights_peak_regression_part4_v2.npz
Traceback (most recent call last):
File "/home/w/anaconda3/envs/torch_2023/bin/TractSeg", line 7, in
exec(compile(f.read(), file, 'exec'))
File "/home/w/soft/TractSeg/bin/TractSeg", line 420, in
main()
File "/home/w/soft/TractSeg/bin/TractSeg", line 325, in main
seg = run_tractseg(data, args.output_type,
File "/home/w/soft/TractSeg/tractseg/python_api.py", line 206, in run_tractseg
model = BaseModel(Config, inference=True)
File "/home/w/soft/TractSeg/tractseg/models/base_model.py", line 106, in init
self.load_model(join(self.Config.EXP_PATH, self.Config.WEIGHTS_PATH))
File "/home/w/soft/TractSeg/tractseg/models/base_model.py", line 280, in load_model
pytorch_utils.load_checkpoint(path, unet=self.net)
File "/home/w/soft/TractSeg/tractseg/libs/pytorch_utils.py", line 20, in load_checkpoint
checkpoint = torch.load(path, map_location=lambda storage, loc: storage)
File "/home/w/anaconda3/envs/torch_2023/lib/python3.9/site-packages/torch/serialization.py", line 795, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/home/w/anaconda3/envs/torch_2023/lib/python3.9/site-packages/torch/serialization.py", line 1020, in _legacy_load
typed_storage._storage.set_from_file(
RuntimeError: unexpected EOF, expected 31322553 more bytes. The file might be corrupted.

The Error in above processing causes further errors when I run the tracking:
The code for tracking that I am running is:
Tracking -i tractseg_output/peaks.nii.gz -o tractseg_output
Here is the further error text:
_/home/w/anaconda3/envs/torch_2023/bin/Tracking:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
import('pkg_resources').require('TractSeg==2.9')
75%|████████████████████████████████▎ | 54/72 [01:44<00:34, 1.94s/it]
Traceback (most recent call last):
File "/home/w/anaconda3/envs/torch_2023/lib/python3.9/site-packages/nibabel/loadsave.py", line 100, in load
stat_result = os.stat(filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tractseg_output/TOM/T_PAR_left.nii.gz'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/w/anaconda3/envs/torch_2023/bin/Tracking", line 7, in
exec(compile(f.read(), file, 'exec'))
File "/home/w/soft/TractSeg/bin/Tracking", line 168, in
main()
File "/home/w/soft/TractSeg/bin/Tracking", line 158, in main
tracking.track(bundle, input_path, Config.PREDICT_IMG_OUTPUT,
File "/home/w/soft/TractSeg/tractseg/libs/tracking.py", line 179, in track
tom_peaks_img = nib.load(output_dir + "/" + TOM_folder + "/" + bundle + ".nii.gz")
File "/home/w/anaconda3/envs/torch_2023/lib/python3.9/site-packages/nibabel/loadsave.py", line 102, in load
raise FileNotFoundError(f"No such file or no access: '{filename}'")
FileNotFoundError: No such file or no access: 'tractseg_output/TOM/T_PAR_left.nii.gz'_

How to solve this problem?

Thank you.

@trinhdh
Copy link

trinhdh commented Oct 22, 2024

@wasserth Could you please update new https://hub.docker.com/r/wasserth/tractseg_container to the latest version ?
Thank you.

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

3 participants