Skip to main content

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 BGR images of shape (H, W, 3)
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')  # You can use either 'pca', 'tsne' or 'umap'                              
im_tsne = plotter.plot(images, feature_vectors, labels)  # Providing labels is optional

The latentplot.Plotter constructor parameters are:

Parameter name Description
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 latent 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

  • CIFAR-10: the size of the images in this dataset is 32x32 pixels. The colour of the rectangle around each image indicates the class label of the image. The colour for each class is randomly chosen in every run.
    • PCA:

      CIFAR-10 PCA
    • t-SNE:

      CIFAR-10 t-SNE
    • UMAP:

      CIFAR-10 UMAP

Notes on dimensionality reduction methods

Author

Luis Carlos Garcia Peraza Herrera (luiscarlos.gph@gmail.com), 2023.

License

This code repository is shared under an MIT license.

Metadata

Release files for latentplot 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for latentplot 0.0.2
File Size Uploaded Provenance Actions
latentplot-0.0.2.tar.gz 12.6 kB Without provenance Details for latentplot-0.0.2.tar.gz

Release files / latentplot-0.0.2.tar.gz

Download URL latentplot-0.0.2.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0a3e514358244c7c68382bd1eda8f4493f690f8299cd1830220286ed015ceb6f
BLAKE2b-256 checksum
How to use checksums
ade1ed7dc340cd2294a0b4d90b27df6058bc0567ea5996501b717b6c4047ffe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for latentplot 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page