.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_apply_regr.py: Example 02: Apply trained network for regression ================================================ This script applies a trained MS-D network for regression (i.e. denoising/artifact removal) Run generatedata.py first to generate required training data and train_regr.py to train a network. .. code-block:: default # Import code import msdnet import glob import tifffile import os # Make folder for output os.makedirs('results', exist_ok=True) # Load network from file n = msdnet.network.MSDNet.from_file('regr_params.h5', gpu=True) # Process all test images flsin = sorted(glob.glob('test/noisy/*.tiff')) for i in range(len(flsin)): # Create datapoint with only input image d = msdnet.data.ImageFileDataPoint(flsin[i]) # Compute network output output = n.forward(d.input) # Save network output to file tifffile.imsave('results/regr_{:05d}.tiff'.format(i), output[0]) .. _sphx_glr_download_auto_examples_apply_regr.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: apply_regr.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: apply_regr.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_