Gaussian processes for image analysis
Project description
Under active development (expect some breaking changes)
What is GPim?
GPim is a python package that provides an easy way to apply Gaussian processes (GP) and GP-based Bayesian optimization to images and hyperspectral data, as well as to theoretical lattice models, in Pyro and Gpytorch (without a need to learn those frameworks).
For the examples, see our papers:
GP for 3D hyperspectral data: https://arxiv.org/abs/1911.11348
GP for 4D hyperspectral data: https://arxiv.org/abs/2002.03591
GP for Ising model: https://arxiv.org/abs/2004.04832
The intended audience are domain scientists (for example, microscopists) with a basic knowledge of python.
Installation
To use it, first run:
pip install gpim
How to use
General usage
Below is a simple example of applying GPim to reconstructing a sparse 2D image. It can be similarly applied to 3D and 4D hyperspectral data. The missing data points in sparse data must be represented as NaNs. In the absense of missing observation GPim can be used for image and spectroscopic data cleaning/smoothing in all the dimensions simultaneously, as well as for the resolution enhancement. Finally, when performing measurements, one can use the information about uncertainty in GP reconstruction to select the next measurement point (more details in the notebooks referenced below).
import gpim
import numpy as np
# # Load dataset
R = np.load('sparse_exp_data.npy')
# Get full (ideal) grid indices
X_full = gpim.utils.get_full_grid(R, dense_x=1)
# Get sparse grid indices
X_sparse = gpim.utils.get_sparse_grid(R)
# Kernel lengthscale constraints (optional)
lmin, lmax = 1., 4.
lscale = [[lmin, lmin], [lmax, lmax]]
# Run GP reconstruction to obtain mean prediction and uncertainty for each predictied point
mean, sd, hyperparams = gpim.reconstructor(
X_sparse, R, X_full, lengthscale=lscale,
learning_rate=0.1, iterations=250,
use_gpu=True, verbose=False).run()
# Plot reconstruction results
gpim.utils.plot_reconstructed_data2d(R, mean, cmap='jet')
# Plot evolution of kernel hyperparameters during training
gpim.utils.plot_kernel_hyperparams(hyperparams)
Running GPim notebooks in the cloud
- Executable Google Colab notebook with the example of applying GP to sparse spiral 2D scans in piezoresponse force microscopy (PFM) and hyperspectral 3D data in Band Excitation PFM.
- Executable Google Colab notebook with the example of applying GP to 4D spectroscopic dataset for smoothing and resolution enhancement in contact Kelvin Probe Force Microscopy (cKPFM).
- Executable Google Colab notebook with a simple example of performing GP-based exploration-exploitation on a toy dataset.
Requirements
It is strongly recommended to run the codes with a GPU hardware accelerator (such as NVIDIA's P100 or V100 GPU). If you don't have a GPU on your local machine, you may rent a cloud GPU from Google Cloud AI Platform. Running the example notebooks one time from top to bottom will cost about 1 USD with a standard deep learning VM instance (one P100 GPU and 15 GB of RAM).
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 gpim-0.2.4.tar.gz
.
File metadata
- Download URL: gpim-0.2.4.tar.gz
- Upload date:
- Size: 26.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e0ddfbb3f9d7256fc3a6fcd1e8868a3a8024031a644da95c7dc5ea7d98f2ff5 |
|
MD5 | dcb6f8d3804e370645aa29233472f07d |
|
BLAKE2b-256 | 476d1dee72048c633e86ae46429fed57644e4ae9ce1a5433ab8c24df1acc0460 |
File details
Details for the file gpim-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: gpim-0.2.4-py3-none-any.whl
- Upload date:
- Size: 33.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e8f1ccb715ef61532f341a03c20e048c866befdcf8b0967d82ee252707fe7b1 |
|
MD5 | 80447cd5e4f325240b428fa7a9d13e98 |
|
BLAKE2b-256 | 0fb4c1ee50d8343844c9e344e26029ad68c563920327d39bc0ed7b5e3037e4cd |