deep perceptual resampling and super resolution with antspyx
Project description
SIQ - super-resolution image quantification
deep perceptual resampling and super-resolution for (medical) imaging
install by calling (within the source directory):
python setup.py install
or install via pip install siq
what this will do
facilitates:
-
creating training and testing data for deep networks
-
generating and testing perceptual losses in 2D and 3D
-
general training and inference functions for deep networks
-
intuitive weighting of multiple losses
-
anisotropic super-resolution
-
evaluation strategies for the above
first time setup
import antspyt1w
antspyt1w.get_data( force_download=True )
# import siq # FIXME - for later
# siq.get_data( force_download=True )
NOTE: get_data
has a force_download
option to make sure the latest
package data is installed.
example processing
import os
import siq
import glob
import ants
fns=glob.glob( os.path.expanduser( "~/.antspyt1w/2*T1w*gz" ) )
import tensorflow as tf
ofn = os.path.expanduser("~/code/DPR/models/dsr3d_2up_64_256_6_3_v0.0zzz.h5")
if os.path.exists( ofn ):
print("existing model") # should always initialize with pre-trained model
mdl = tf.keras.models.load_model( ofn, compile=False )
else:
print("default model - initialized with random weights")
mdl = siq.default_dbpn( [2,2,2] ) # should match ratio of high to low size patches
myoutprefix = '/tmp/XXX'
training_path = siq.train(
mdl,
fns[0:3],
fns[0:3],
output_prefix=myoutprefix,
target_patch_size=[32,32,32],
target_patch_size_low=[16,16,16],
n_test=2,
learning_rate=5e-05,
feature_layer=6,
feature=2,
tv=0.1,
max_iterations=2,
verbose=True)
training_path.to_csv( myoutprefix + "_training.csv" )
image = ants.image_read( fns[0] )
image = ants.resample_image( image, [48,48,48] ) # downsample for speed in testing
test = siq.inference( image, mdl )
see also: the training scripts in tests
.
todo
-
numpy read/write
-
test/fix 2D
your compute environment
export TF_ENABLE_ONEDNN_OPTS=1 # for CPU
total_cpu_cores=$(nproc)
number_sockets=$(($(grep "^physical id" /proc/cpuinfo | awk '{print $4}' | sort -un | tail -1)+1))
number_cpu_cores=$(( (total_cpu_cores/2) / number_sockets))
echo "number of CPU cores per socket: $number_cpu_cores";
echo "number of socket: $number_sockets";
echo "Physical cores:"
egrep '^core id' /proc/cpuinfo | sort -u | wc -l
echo "Logical cores:"
egrep '^processor' /proc/cpuinfo | sort -u | wc -l
echo "Physical cpus (separate chips):"
egrep '^physical id' /proc/cpuinfo | sort -u | wc -l
to publish a release
rm -r -f build/ antspymm.egg-info/ dist/
python3 setup.py sdist bdist_wheel
python3 -m twine upload -u username -p password dist/*
notes on cpu environment
# dd=/home/ubuntu/miniconda3/condabin/conda
# conda update -n base -c defaults conda
# conda init bash
# conda create -n ai3 python=3.9
# conda activate ai3
# pip3 install --upgrade pip
py=python3 # "sudo /opt/parallelcluster/pyenv/versions/3.7.10/envs/awsbatch_virtualenv/bin/python3.7"
$py -m pip install --upgrade pip
# python3.7 -m pip uninstall tensorflow antspynet dipy patsy tensorboard tensorflow-probability -y
$py -m pip install nibabel PyNomaly scipy
$py -m pip install antspyx
$py -m pip install dipy
$py -m pip install antspyt1w
$py -m pip install antspymm
$py -m pip install antspynet
$py -m pip install siq
$py -m pip uninstall tensorflow -y
$py -m pip install intel-tensorflow # -avx512==2.9.1
$py -m pip install tensorflow_probability
$py -m pip install keras
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file siq-0.3.4.tar.gz
.
File metadata
- Download URL: siq-0.3.4.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ab8ddfa16d4e4a4cb1aaee83365c5af800353bbaa9027ba2fda2b2ac297ffc8 |
|
MD5 | 4bf807e4826cad99b1f2b6beef9483f2 |
|
BLAKE2b-256 | ace87ff42a4497f42702b1d733ae82b693e8fa47e0bdb7a9da9ade4a683e8604 |
File details
Details for the file siq-0.3.4-py3-none-any.whl
.
File metadata
- Download URL: siq-0.3.4-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b03513cf67d393a1014be54595bbf055c804965929adf630e6cb0508250420bb |
|
MD5 | 00041b8712c767c97b5c1ad48b6add05 |
|
BLAKE2b-256 | 2627b56e38f46478eeda80a30a4e547b37506dac71dc680f08b233207e117721 |