Show more images in Tensorboard - Tensorflow object detection
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
When training object detection models, scalar metrics rarely tell the whole story. Seeing more annotated images in TensorBoard helps you catch bad labels, box misalignment, augmentation problems, and class confusion much earlier, and the key control is usually how many images you log with each image summary.
The Main Lever: max_outputs
If you only see a few images, your summary call is probably logging too few outputs. Increase max_outputs in tf.summary.image():
Two things matter here:
- '
max_outputscannot exceed the batch size' - you must flush or close the writer for summaries to appear promptly
Raw Images Are Less Useful Than Annotated Images
For object detection, the real value comes from images with ground-truth and predicted boxes drawn on them. A simplified example using tf.image.draw_bounding_boxes looks like this:
That is much more informative than logging raw input images alone.
Compare Ground Truth and Predictions Side by Side
One practical debugging pattern is to place ground truth and prediction panels next to each other:
When you log a batch of these panels, TensorBoard becomes much more useful for diagnosing whether the model is missing objects, hallucinating boxes, or drifting during training.
Control Logging Frequency
Image summaries are expensive compared with scalar summaries. Logging high-resolution images every step can slow training and produce very large event files.
A better pattern is to log at intervals:
This gives you useful visual checkpoints without turning TensorBoard logging into a storage problem.
Make Sure the Image Tensor Is Valid
A surprising amount of TensorBoard confusion comes from bad image formatting rather than the summary API itself. Confirm:
- shape is
(batch, height, width, channels) - values are in a sensible range
- dtype is appropriate for the summary
If the image looks washed out or clipped, normalize and convert the data before writing the summary.
Batch Size Still Limits What You See
Even with max_outputs=20, a batch of 4 images will only show 4. That means if you want more samples visible per step, you may need:
- a larger evaluation batch
- a separate debug batch
- or several summary calls across different steps
The summary function cannot log images that are not present in the tensor you give it.
Common Pitfalls
- Increasing
max_outputswithout noticing that the batch itself is smaller. - Logging only raw images instead of useful annotated debug views.
- Writing image summaries every step and creating huge event files.
- Forgetting to flush the summary writer.
- Passing badly scaled or wrongly shaped image tensors into
tf.summary.image().
Summary
- Increase
max_outputsto show more images per TensorBoard image summary. - For object detection, annotated images are much more useful than raw inputs.
- Side-by-side ground truth and prediction panels are a strong debugging pattern.
- Log images at intervals instead of every step to control cost.
- Verify batch size, tensor shape, dtype, and value range before blaming TensorBoard.
Related reading
- Show progress bar for each epoch during batchwise training in Keras
- Show training and validation accuracy in TensorFlow using same graph
- shuffle in the model.fit of keras
- Shuffling training data with LSTM \`RNN\`
- Show training and validation accuracy in TensorFlow using same graph
- Shuffling the training dataset with Tensorflow object detection api
- Simple Digit Recognition OCR in OpenCV-Python
- Sizes of positive and negative images using Haar Cascade
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack 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.