Python module to produce an image plot of latent spaces.
Project description
Description
Python package to plot the latent space of a set of images with different methods.
Install with pip
$ python3 -m pip install latentplot --user
Install from source
$ git clone https://github.com/luiscarlosgph/latentplot.git
$ cd latentplot
$ python3 setup.py install --user
Exemplary code snippet
# List of images of shape (H, W, 3) and BGR
images = [ ... ]
# List of vectors of shape (D,), where D is the vector dimension
feature_vectors = [ ... ]
# List of integer class labels
labels = [ ... ]
# Produce a BGR image containing a 2D plot of the latent space with t-SNE
plotter = latentplot.Plotter(method='tsne')
im_tsne = plotter.plot(images, feature_vectors, labels) # Providing labels here is optional
The latentplot.Plotter
constructor parameters are:
- method: method used to reduce the feature vectors to a 2D space. Available options: pca, tsne, umap.
- width: desired output image width. Default is 15360 pixels (16K).
- height: desired output image height. Default is 8640 pixels (16K).
- dpi: DPI for the output image. Default is 300.
- cell_factor: proportion of the reduced space that each cell will occupy. Default is 0.01.
- dark_mode: set it to False to have a white background with black font. Default is True.
- hide_axes: hide axes, ticks and marks. Default is True.
- **kwargs: the rest of the arguments you pass will be forwarded to the dimensionality reduction method.
Exemplary results
Author
Luis Carlos Garcia Peraza Herrera (luiscarlos.gph@gmail.com), 2023.
License
This code repository is shared under an MIT license.
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
latentplot-0.0.1.tar.gz
(8.4 kB
view hashes)
Built Distribution
latentplot-0.0.1-py3.9.egg
(12.6 kB
view hashes)