From c9b807b199f55f193bb88dd24d47d98abfe47ee5 Mon Sep 17 00:00:00 2001 From: tibuch Date: Mon, 11 Jan 2021 16:17:45 +0100 Subject: [PATCH 1/2] Apply attenuation function to all bin-levels. * Bump version * Update README.md --- README.md | 4 ++-- fit/modules/TRecTransformerModule.py | 29 +++++++++++----------------- fit/version.py | 2 +- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 964d6ba..7a1ecca 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Build Python package: `python setup.py bdist_wheel` Build singularity recipe: -`neurodocker generate singularity -b nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04 -p apt --copy /home/tibuch/Gitrepos/FourierImageTransformer/dist/fourier_image_transformers-0.1.3-py3-none-any.whl /fourier_image_transformers-0.1.3-py3-none-any.whl --miniconda create_env=fit conda_install='python=3.7 astra-toolbox pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch -c astra-toolbox/label/dev' pip_install='/fourier_image_transformers-0.1.3-py3-none-any.whl' activate=true --entrypoint "/neurodocker/startup.sh python" > v0.1.3.Singularity` +`neurodocker generate singularity -b nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04 -p apt --copy /home/tibuch/Gitrepos/FourierImageTransformer/dist/fourier_image_transformers-0.1.4-py3-none-any.whl /fourier_image_transformers-0.1.4-py3-none-any.whl --miniconda create_env=fit conda_install='python=3.7 astra-toolbox pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch -c astra-toolbox/label/dev' pip_install='/fourier_image_transformers-0.1.4-py3-none-any.whl' activate=true --entrypoint "/neurodocker/startup.sh python" > v0.1.4.Singularity` Build singularity container: -`sudo singularity build fit_v0.1.3.simg v0.1.3.Singularity` \ No newline at end of file +`sudo singularity build fit_v0.1.4.simg v0.1.4.Singularity` \ No newline at end of file diff --git a/fit/modules/TRecTransformerModule.py b/fit/modules/TRecTransformerModule.py index b79dfc9..9ae9ce9 100644 --- a/fit/modules/TRecTransformerModule.py +++ b/fit/modules/TRecTransformerModule.py @@ -88,24 +88,17 @@ def configure_optimizers(self): } def _real_loss(self, pred_fc, target_fc, target_real, mag_min, mag_max): - if self.bin_factor == 1: - dft_pred = convert_to_dft(fc=pred_fc, mag_min=mag_min, mag_max=mag_max, - dst_flatten_coords=self.dst_flatten_coords, img_shape=self.hparams.img_shape) - y_hat = torch.roll(torch.fft.irfftn(dft_pred, dim=[1, 2], s=2 * (self.hparams.img_shape,)), - 2 * (self.hparams.img_shape // 2,), (1, 2)) - return F.mse_loss(y_hat, target_real) - else: - dft_pred = convert_to_dft(fc=pred_fc, mag_min=mag_min, mag_max=mag_max, - dst_flatten_coords=self.dst_flatten_coords, img_shape=self.hparams.img_shape) - dft_target = convert_to_dft(fc=target_fc, mag_min=mag_min, mag_max=mag_max, - dst_flatten_coords=self.dst_flatten_coords, img_shape=self.hparams.img_shape) - dft_pred *= self.mask - dft_target *= self.mask - y_hat = torch.roll(torch.fft.irfftn(dft_pred, dim=[1, 2], s=2 * (self.hparams.img_shape,)), - 2 * (self.hparams.img_shape // 2,), (1, 2)) - y_target = torch.roll(torch.fft.irfftn(dft_target, dim=[1, 2], s=2 * (self.hparams.img_shape,)), - 2 * (self.hparams.img_shape // 2,), (1, 2)) - return F.mse_loss(y_hat, y_target) + dft_pred = convert_to_dft(fc=pred_fc, mag_min=mag_min, mag_max=mag_max, + dst_flatten_coords=self.dst_flatten_coords, img_shape=self.hparams.img_shape) + dft_target = convert_to_dft(fc=target_fc, mag_min=mag_min, mag_max=mag_max, + dst_flatten_coords=self.dst_flatten_coords, img_shape=self.hparams.img_shape) + dft_pred *= self.mask + dft_target *= self.mask + y_hat = torch.roll(torch.fft.irfftn(dft_pred, dim=[1, 2], s=2 * (self.hparams.img_shape,)), + 2 * (self.hparams.img_shape // 2,), (1, 2)) + y_target = torch.roll(torch.fft.irfftn(dft_target, dim=[1, 2], s=2 * (self.hparams.img_shape,)), + 2 * (self.hparams.img_shape // 2,), (1, 2)) + return F.mse_loss(y_hat, y_target) def _fc_loss(self, pred_fc, target_fc): return F.mse_loss(pred_fc, target_fc) diff --git a/fit/version.py b/fit/version.py index 8ce9b36..7525d19 100644 --- a/fit/version.py +++ b/fit/version.py @@ -1 +1 @@ -__version__ = '0.1.3' +__version__ = '0.1.4' From 38171e263cdca4350bc66c1f2861a7d1c8b73c3b Mon Sep 17 00:00:00 2001 From: tibuch Date: Mon, 11 Jan 2021 16:19:51 +0100 Subject: [PATCH 2/2] Add singularity recipe for v0.1.4. --- singularity/v0.1.4.Singularity | 138 +++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 singularity/v0.1.4.Singularity diff --git a/singularity/v0.1.4.Singularity b/singularity/v0.1.4.Singularity new file mode 100644 index 0000000..4174ef9 --- /dev/null +++ b/singularity/v0.1.4.Singularity @@ -0,0 +1,138 @@ +# Generated by: Neurodocker version 0.7.0 +# Latest release: Neurodocker version 0.7.0 +# Timestamp: 2021/01/11 15:19:18 UTC +# +# Thank you for using Neurodocker. If you discover any issues +# or ways to improve this software, please submit an issue or +# pull request on our GitHub repository: +# +# https://github.com/ReproNim/neurodocker + +Bootstrap: docker +From: nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04 + +%post +su - root + +export ND_ENTRYPOINT="/neurodocker/startup.sh" +apt-get update -qq +apt-get install -y -q --no-install-recommends \ + apt-utils \ + bzip2 \ + ca-certificates \ + curl \ + locales \ + unzip +apt-get clean +rm -rf /var/lib/apt/lists/* +sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen +dpkg-reconfigure --frontend=noninteractive locales +update-locale LANG="en_US.UTF-8" +chmod 777 /opt && chmod a+s /opt +mkdir -p /neurodocker +if [ ! -f "$ND_ENTRYPOINT" ]; then + echo '#!/usr/bin/env bash' >> "$ND_ENTRYPOINT" + echo 'set -e' >> "$ND_ENTRYPOINT" + echo 'export USER="${USER:=`whoami`}"' >> "$ND_ENTRYPOINT" + echo 'if [ -n "$1" ]; then "$@"; else /usr/bin/env bash; fi' >> "$ND_ENTRYPOINT"; +fi +chmod -R 777 /neurodocker && chmod a+s /neurodocker + +export PATH="/opt/miniconda-latest/bin:$PATH" +echo "Downloading Miniconda installer ..." +conda_installer="/tmp/miniconda.sh" +curl -fsSL --retry 5 -o "$conda_installer" https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh +bash "$conda_installer" -b -p /opt/miniconda-latest +rm -f "$conda_installer" +conda update -yq -nbase conda +conda config --system --prepend channels conda-forge +conda config --system --set auto_update_conda false +conda config --system --set show_channel_urls true +sync && conda clean -y --all && sync +conda create -y -q --name fit +conda install -y -q --name fit \ + "python=3.7" \ + "astra-toolbox" \ + "pytorch" \ + "torchvision" \ + "torchaudio" \ + "cudatoolkit=10.2" \ + "-c" \ + "pytorch" \ + "-c" \ + "astra-toolbox/label/dev" +sync && conda clean -y --all && sync +bash -c "source activate fit + pip install --no-cache-dir \ + "/fourier_image_transformers-0.1.4-py3-none-any.whl"" +rm -rf ~/.cache/pip/* +sync +sed -i '$isource activate fit' $ND_ENTRYPOINT + + +echo '{ +\n "pkg_manager": "apt", +\n "instructions": [ +\n [ +\n "base", +\n "nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04" +\n ], +\n [ +\n "user", +\n "root" +\n ], +\n [ +\n "_header", +\n { +\n "version": "generic", +\n "method": "custom" +\n } +\n ], +\n [ +\n "copy", +\n [ +\n "/home/tibuch/Gitrepos/FourierImageTransformer/dist/fourier_image_transformers-0.1.4-py3-none-any.whl", +\n "/fourier_image_transformers-0.1.4-py3-none-any.whl" +\n ] +\n ], +\n [ +\n "miniconda", +\n { +\n "create_env": "fit", +\n "conda_install": [ +\n "python=3.7", +\n "astra-toolbox", +\n "pytorch", +\n "torchvision", +\n "torchaudio", +\n "cudatoolkit=10.2", +\n "-c", +\n "pytorch", +\n "-c", +\n "astra-toolbox/label/dev" +\n ], +\n "pip_install": [ +\n "/fourier_image_transformers-0.1.4-py3-none-any.whl" +\n ], +\n "activate": true +\n } +\n ], +\n [ +\n "entrypoint", +\n "/neurodocker/startup.sh python" +\n ] +\n ] +\n}' > /neurodocker/neurodocker_specs.json + +%environment +export LANG="en_US.UTF-8" +export LC_ALL="en_US.UTF-8" +export ND_ENTRYPOINT="/neurodocker/startup.sh" +export CONDA_DIR="/opt/miniconda-latest" +export PATH="/opt/miniconda-latest/bin:$PATH" + +%files +/home/tibuch/Gitrepos/FourierImageTransformer/dist/fourier_image_transformers-0.1.4-py3-none-any.whl /fourier_image_transformers-0.1.4-py3-none-any.whl + +%runscript +/neurodocker/startup.sh python