Fnet setup

Label-free prediction of three-dimensional fluorescence images from transmitted light microscopy by Allen Institute

Chang-Min Hsu, Wen-Wei Tseng

Link to paper: http://dx.doi.org/10.1038/s41592-018-0111-2

The Nextjournal pytorch enviroment

Nextjournal had K80 as the GPU and CUDA 9.2 as runtime.

Python and PyTorch versions are listed below.

import platform, torch
print("Python version: %s.\nPyTorch version: %s." %
      (platform.python_version(),torch.__version__))
0.7s
PyTorch (Python)

Cloning the repository

Using release_1 branch to reporduce the results in the Nature paper.

Not required in the Nextjournal notebook.

cd ~
git clone https://github.com/AllenCellModeling/pytorch_fnet.git -b release_1
9.1s
PyTorch (Bash in Python)

Changes I made

The newer GPU models (e.g. Titan V) do not work on older pytorch versions as well as CUDA9 runtime. CUDA compile error would occur. Thus I had to remove version constraints on both pytorch and torchvision packages in environment.yml. As a result, the latest PyTorch and CUDA 10 will be installed.

The environment file by me:

environment.yml

To create and activate fnet enviroment in conda

Not required in the Nextjournal notebook as the environment is already set up.

conda create -f NJ__REF_
conda activate fnet
Shift+Enter to run
PyTorch (Bash in Python)

Installing fnet packages in the repo

Note: Install fnet package before download data or you'll overflow the temp directory from pip caching and the content in the repository.

cd ~/pytorch_fnet  # The folder where the repo resides
pip install .
18.2s
PyTorch (Bash in Python)

Fix 'cannot import name imsave'

imsave() is deprecated and removed since scipy 1.2.0. Installing the older one instead.

pip install scipy==1.1.0
9.8s
PyTorch (Bash in Python)
# List packages
conda list
Shift+Enter to run
PyTorch (Bash in Python)

Test run

cd ~/pytorch_fnet
chmod +x ./scripts/test_run.sh
./scripts/test_run.sh
76.5s
PyTorch (Bash in Python)

Downloading dataset

https://downloads.allencell.org/publication-data/label-free-prediction/index.html

./scripts/paper/download_all_data.sh
Bash

Downloads all data (do not do this in the Nextjournal Notebook).

They are over 500GB in total so a large enough storage is required. I put them in the NAS and mount it via SMB.

sudo mount -t cifs -o username=sosiristseng,password=********,gid=1000,uid=1000 //<NAS IP address>/lab /home/sosiristseng/lab
Bash

Train a model

For example, to train the DNA image model with the first GPU:

./scripts/train_model.sh dna 0
Bash

Run predictions with the trained model

./scripts/predict.sh dna 0
Bash

Benchmarking

  • GTX 1080 Ti: 16 hrs per dataset

  • Titan V: 14.5 hrs (52400 secs) per dataset

Consistent with this benchmark

Visualizing .czi files

  1. Download and extract ImageJ

  2. Dwonload BioFormats .jar package and put it into the folder of ImageJ

  3. Profit!

Runtimes (1)