Skip to content

Latest commit

 

History

History
88 lines (58 loc) · 3.25 KB

File metadata and controls

88 lines (58 loc) · 3.25 KB

Hands-on Session 3.1: Image Reconstruction using the PyTorch and Spyrit Packages

This code was used during a hands-on session given at the Deep Learning for Medical Imaging School 2021.

The session was a practical introduction to image reconstruction, considering the limited-angle computed tomography problem. Participants were invited to run the cells, answer the questions, and fill in blanks in the code of main.ipynb. All answers and the solution code are given in main_with_answers.ipynb

The hands-on session followed a presentation. Check the slides or watch the video.

Authors: N Ducros, T Leuliet, A Lorente Mur, L Friot--Giroux, T. Grenier

Contact: [email protected], CREATIS Laboratory, University of Lyon, France.

Install the dependencies

  1. We recommend creating a virtual (e.g., conda) environment first.

    # conda (or pip) install
    conda create --name new-env
    conda activate new-env
    conda install -c anaconda spydery
    conda install -c conda-forge jupyterlab
    conda install -c anaconda scikit-image
    conda install -c anaconda h5py 
    conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch # for windows

    Alternatively, you can clone an existing environment with conda create --name new-env --clone existing-env

    Our scripts primarily relies on the SPyRiT package that can be installed via pip. NB: On Windows, you need to install torch before SPyRiT

    # pip install
    pip install spyrit # tested with spyrit==1.1.0

Get the scripts and data

  1. Get source code from GitHub

     git clone https://github.com/openspyrit/spyrit-examples.git        
    
  2. Go into spyrit-examples/2021_DLMIS_Hands-on/

    cd spyrit-examples/2021_DLMIS_Hands-on/    
    
  3. Download the image database at this url and extract its content

    • Windows PowerShell
    wget https://www.creatis.insa-lyon.fr/~ducros/spyritexamples/2021_DLMIS_Hands-on/data.zip -outfile data.zip
    tar xvf data.zip 

    The directory structure should be

     |---spyrit-examples
     |   |---2021_DLMIS_Hands-on
     |   |   |---data
     |   |   |   |---
     |   |   |---main.ipynb
     |   |   |---main_with_answers.ipynb
     |   |   |---train.py
    
  4. Open JupyterLab environment and create a kernel (e.g., dlmis21) corresponding to your current conda environment

     ipython kernel install --user --name=dlmis21
     jupyter lab
    

Training a model from scratch

We provide train.py to train a network from a single command line

python train.py

By default, all networks are trained for 60 view angles during 20 epochs. For other values (e.g., 40 angles and 100 epochs), consider

python train.py --angle_nb 40 --num_epochs 100

To specify training parameters such as the batch size or learning rate, and for other options, type python train.py --help