Preparing TIFF images for image translation with Pix2Pix

Your guide to getting started with pix2pix using tiff images

Nov 22 ·3min read

G enerative Adversarial Networks (GANs) have gained a lot of attention recently for the impressive feats they have achieved, ranging from image generation, image translation, style transfer, image colorization and so on. In particular, pix2pix, developed by Isola et al., has become very popular as a Conditional Generative Adversarial Network (CGAN), which allows users to generate images based on an input image. Some examples include translating from semantic labelled images to a street scene, daytime photos to nighttime photos, sketches to photos and so on.

Image taken from

All these are very impressive, but currently, pix2pix is catered mostly to PNG and JPG images. This is unfortunate as some tasks, for example medical imaging, use TIFF images which are lossless, whereas standard JPEG files are lossless, hence capturing more accurate details. TIFF images have float values whereas PNG and JPG images have integer values, so it is important to preserve this precision when implementing pix2pix.

Furthermore, CGANs require images to be scaled to the range of [-1, 1] for more stable training. However, normalization isn’t so straight forward by simply using an out-of-the-box function because TIFF images, unlike standard PNG and JPG images that have pixel values from 0–255, can have varying values. In my case, my TIFF images had values ranging from 0–1200!

Keeping these points in mind, I will detail how you can apply pix2pix to your TIFF images successfuly.