Interactive visualization of stable diffusion image embeddings

A great site to discover images generated by stable diffusion (or their custom model called aperture) is Lexica.art. Lexica provides an API which can be used to query images matching some keyword / topic. The API returns image URLs, sizes and other things like the prompt used to generate the image and its seed. The goal of this blog post is to visualize the similarity of images from different categories in an interactive plot which can be explored in the browser.
Read more →

Creating Pleasant Plots With Seaborn

Creating pleasant plots with seaborn Seaborn is an awesome Python library to create great-looking data plots. It’s a bit higher level than the often used matplotlib and this blog entry serves as a self-reminder about the most frequently used plots for myself. It’s way to specify in a declarative way what you want to plot rather than plot details like markers, colors etc is refreshing and frees some cognitive space which you can use for other tasks.
Read more →

How to properly manage ssh keys for server access

This article was on the hacker news frontpage. You can find the related discussion here. Every developer needs access to some servers for example to check the application logs. Usually, this is done using public-private key encryption where each developer generates their own public-private key pair. The public keys of each developer are added to the authorized_keys file on each server they should have access to. Painful manual changes So far so good.
Read more →

Plot PyTorch tensors with matplotlib

Have you ever tried to plot a PyTorch tensor with matplotlib like: plt.plot(tensor) and then received the following error? AttributeError: 'Tensor' object has no attribute 'ndim' You can get around this easily by letting all PyTorch tensors know how to respond to ndim like this: torch.Tensor.ndim = property(lambda self: len(self.shape)) Basically, this uses the property decorator to create ndim as a property which reads its value as the length of self.
Read more →

Writing command-line tools in Python: argument parsing

Python is a great language to build command-line tools in as it’s very expressive and concise. You want to have the ability to parse arguments in your scripts as you don’t want to hard-code the relevant variable values to make the tool useful. So how do we go about this in Python? It’s easily done using the argparse module. With argparse, you define the different arguments which you expect, their default values and their shortcuts to call them.
Read more →