fepegar / highresnet

PyTorch implementation of HighRes3DNet
MIT License
48 stars 15 forks source link

Error trying to execute deepgif #35

Closed GabriellaKamlish closed 3 years ago

GabriellaKamlish commented 3 years ago

Torch version: 1.6.0

Description

I'm attempting to execute the deepgif model for a t1 image by executing the following in the terminal:

$ deepgif t1.nii.gz 

However I seem to be receiving this Traceback error:

Detected orientation: PIR. Reorienting to RAS...
Downloading: "https://github.com/fepegar/highresnet/archive/master.zip" to /Users/gabriellakamlish/.cache/torch/hub/master.zip
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1317, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 956, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1392, in connect
    server_hostname=server_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket
    session=session
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/deepgif", line 10, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/hi  k  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/hi  k/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/hi    rv = self.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/highresnet/cli/deepgif.py", line 84, in main
    use_niftynet_hist_std=hist_niftynet,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/highresnet/inference.py", line 43, in infer
    get_model(),
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/highresnet/inference.py", line 140, in get_model
    model = torch.hub.load(repo, model_name, pretrained=True)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torch/hub.py", line 368, in load
    repo_or_dir = _get_cache_or_reload(repo_or_dir, force_reload, verbose)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torch/hub.py", line 141, in _get_cache_or_reload
    download_url_to_file(url, cached_file, progress=False)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torch/hub.py", line 425, in download_url_to_file
fepegar commented 3 years ago

Thanks for reporting. Are you using conda? It doesn't look like it. Can you try a fresh conda environment?

Can you try these lines?: https://github.com/fepegar/highresnet#pytorch-hub

GabriellaKamlish commented 3 years ago

I'm using conda version 4.8.5. I've tried creating a new conda environment, and have also replaced the step "2. Install PyTorch and highresnet" from: pip install pytorch highresnet to pip3 install torch highresnet since this is the correct package name for PyTorch. I am still receiving the same traceback error

fepegar commented 3 years ago

It would help if you could paste a minimal working example that I can try to reproduce (from creating the conda environment to running the command that generates the error). Also, please try running the lines I mentioned above.

GabriellaKamlish commented 3 years ago

Firstly:

ENVNAME="gifenv"
conda create -n $ENVNAME python -y
conda activate gifenv

Then:

pip install pytorch highresnet

Which returns

  Using cached pytorch-1.0.2.tar.gz (689 bytes)
Collecting highresnet
  Using cached highresnet-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting numpy
  Downloading numpy-1.19.4-cp39-cp39-macosx_10_9_x86_64.whl (15.4 MB)
     |████████████████████████████████| 15.4 MB 3.6 MB/s 
Collecting nibabel
  Downloading nibabel-3.2.0-py3-none-any.whl (3.3 MB)
     |████████████████████████████████| 3.3 MB 2.7 MB/s 
Collecting Click>=7.0
  Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting SimpleITK
  Downloading SimpleITK-1.2.0.tar.gz (2.0 MB)
     |████████████████████████████████| 2.0 MB 2.8 MB/s 
    ERROR: Command errored out with exit status 1:
     command: /Users/gabriellakamlish/anaconda3/envs/gifenv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/jx/g1ztx09x4_q4x9sw1sc7hrnm0000gn/T/pip-install-7_f_wpso/simpleitk/setup.py'"'"'; __file__='"'"'/private/var/folders/jx/g1ztx09x4_q4x9sw1sc7hrnm0000gn/T/pip-install-7_f_wpso/simpleitk/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/jx/g1ztx09x4_q4x9sw1sc7hrnm0000gn/T/pip-pip-egg-info-tek2ng2l
         cwd: /private/var/folders/jx/g1ztx09x4_q4x9sw1sc7hrnm0000gn/T/pip-install-7_f_wpso/simpleitk/
    Complete output (4 lines):
    scikit-build is required to build from source.
    Please run:

      python -m pip install scikit-build
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Then:

 python -m pip install scikit-build

Then again:

pip install pytorch highresnet

Which returns:

Collecting pytorch
  Using cached pytorch-1.0.2.tar.gz (689 bytes)
Collecting highresnet
  Using cached highresnet-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting numpy
  Using cached numpy-1.19.4-cp39-cp39-macosx_10_9_x86_64.whl (15.4 MB)
Collecting tqdm
  Using cached tqdm-4.52.0-py2.py3-none-any.whl (71 kB)
Collecting nibabel
  Using cached nibabel-3.2.0-py3-none-any.whl (3.3 MB)
ERROR: Could not find a version that satisfies the requirement torch>=1.1 (from highresnet) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch>=1.1 (from highresnet)
fepegar commented 3 years ago

Thanks. I'll try this on macOS as soon as I can.

For now, you can use Google Colab. Change the runtime type to GPU and you can do

!pip install highresnet
!NII_FILE=`download_oasis` && deepgif $NII_FILE

This would be very slow on your mac anyway, as you don't have a large NVIDIA GPU you can use for the inference.