Tensorflow
Tensorboard
Image Embedding
Data Visualization
Machine Learning

Tensorflow Enlarge images on Tensorboard embedding?

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

Introduction

In TensorBoard's embedding projector, the image thumbnails do not come from arbitrary zoom settings in the UI. They come from the sprite image and the per-thumbnail dimensions you configure, so if the images look too small or blurry, the fix is usually to generate a larger, cleaner sprite sheet and set the correct single_image_dim.

How Image Thumbnails Work in the Projector

The projector does not store thousands of separate image files. Instead, it expects one large sprite image containing a grid of thumbnails, plus configuration that tells TensorBoard how big each tile is.

The two important settings are:

  • 'image_path, which points to the sprite image'
  • 'single_image_dim, which describes the height and width of each thumbnail'

If each image tile is only 28 x 28, TensorBoard can only display a 28 x 28 thumbnail. No amount of wishful thinking in the UI creates extra detail that is not present in the sprite.

Create a Larger Sprite Image

Suppose you have small grayscale images and want them to appear more clearly in the projector. Start by resizing or preparing each thumbnail at a larger size before combining them into the sprite.

Here is a simple example using Pillow:

python
1from math import ceil, sqrt
2from pathlib import Path
3from PIL import Image
4
5def create_sprite(image_paths, output_path, thumb_size=(64, 64)):
6    images = []
7    for path in image_paths:
8        image = Image.open(path).convert("RGB")
9        image = image.resize(thumb_size)
10        images.append(image)
11
12    grid_size = ceil(sqrt(len(images)))
13    sprite = Image.new(
14        "RGB",
15        (grid_size * thumb_size[0], grid_size * thumb_size[1]),
16        color=(255, 255, 255),
17    )
18
19    for index, image in enumerate(images):
20        row = index // grid_size
21        col = index % grid_size
22        sprite.paste(image, (col * thumb_size[0], row * thumb_size[1]))
23
24    sprite.save(output_path)
25
26paths = sorted(Path("samples").glob("*.png"))
27create_sprite(paths, "logs/sprite.png", thumb_size=(64, 64))

If your current thumbnails are tiny, increasing thumb_size is the main way to make them easier to inspect.

Wire the Sprite into TensorBoard

After creating the sprite image, configure the projector:

python
1import os
2import tensorflow as tf
3from tensorboard.plugins import projector
4
5log_dir = "logs"
6embedding = tf.Variable(tf.random.normal([100, 32]), name="image_embedding")
7checkpoint = tf.train.Checkpoint(embedding=embedding)
8checkpoint.save(os.path.join(log_dir, "embedding.ckpt"))
9
10config = projector.ProjectorConfig()
11embedding_config = config.embeddings.add()
12embedding_config.tensor_name = "image_embedding/.ATTRIBUTES/VARIABLE_VALUE"
13embedding_config.sprite.image_path = "sprite.png"
14embedding_config.sprite.single_image_dim.extend([64, 64])
15
16projector.visualize_embeddings(log_dir, config)

The important line for image size is:

python
embedding_config.sprite.single_image_dim.extend([64, 64])

If the actual sprite tiles are 64 x 64, that is what you should declare. If you lie about the dimensions, thumbnails will be sliced incorrectly and the result will look broken.

Bigger Thumbnails Versus More Points

There is a tradeoff. Larger thumbnails make each image easier to inspect, but they also make the sprite file larger and the projector heavier to load.

If you try to visualize thousands of high-resolution thumbnails at once, the projector can become slow or memory-hungry. In practice, it is often better to:

  • use moderate thumbnail sizes such as 48 x 48 or 64 x 64
  • sample a subset of points for visual inspection
  • keep the original images elsewhere for detailed review

The embedding projector is best at showing neighborhood structure and clusters. It is not a full image-browser application.

When Images Still Look Small

If the thumbnails are technically larger but still hard to inspect, the issue may be density rather than image resolution. When too many points are packed together, each one becomes visually crowded.

Possible fixes:

  • log fewer embeddings
  • separate classes into multiple runs
  • filter to a representative subset
  • use metadata labels so you do not rely only on the thumbnail itself

That often produces a more useful visualization than pushing thumbnail size ever higher.

Common Pitfalls

The most common mistake is increasing the size of the original training images but keeping a tiny sprite thumbnail size. TensorBoard only sees the sprite tiles.

Another issue is mismatching single_image_dim and the actual tile size in the sprite. If the sprite was built with 32 x 32 tiles but the config says 64 x 64, the thumbnails will be misaligned.

People also try to solve a density problem with resolution alone. If thousands of images are crowded together, larger thumbnails may not help much.

Finally, remember that the projector uses the sprite image as a visualization aid. It does not change the embedding vectors themselves. Bigger thumbnails improve inspection, not the underlying model.

Summary

  • TensorBoard projector image size is driven by the sprite sheet and single_image_dim.
  • To enlarge thumbnails, create a sprite image with larger tiles.
  • Set embedding_config.sprite.single_image_dim to the real thumbnail size you used.
  • Larger thumbnails improve readability but increase file size and UI load.
  • If the view is still crowded, reduce the number of displayed embeddings instead of only enlarging the images.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

All Rights Reserved.