liveBook · Manning

Resolution

As explained in Learn Generative AI with PyTorch

The pixel dimensions of an image, used here to compare lower- and higher-resolution generated images.

Resolution is an image’s pixel dimensions. In generated-image projects, it distinguishes smaller 64 × 64 images from higher-resolution 256 × 256 images. section 5.4.1

Higher resolution changes both the generated result and the training requirements:

  • A 256 × 256 color image becomes a 3 × 256 × 256 channel-first tensor in PyTorch. section 5.4.1
  • Larger images require more memory, so a batch size of 16 may need to be reduced to 10 or 8. section 5.4.1
  • More sophisticated generators and discriminators can use 2D convolutional and transposed-convolutional layers for color images. section 4.4
import torchvision.transforms as T
import torchvision
 
batch_size=16
imgsz=256
transform=T.Compose([
   T.Resize((imgsz,imgsz)),
   T.ToTensor(),
   T.Normalize([0.5,0.5,0.5],[0.5,0.5,0.5])])      
data_set=torchvision.datasets.ImageFolder(
   root=r"files/glasses",
   transform=transform) 

Resize training images to 256 × 256 pixels, convert them to tensors, and normalize their color values before loading them. section 5.4.1

How Learn Generative AI with PyTorch covers it

How deep it goes
Defines resolution through 64 × 64 and 256 × 256 examples, then traces tensor shape and batch-size consequences.
Examples
Uses 64 × 64 and 256 × 256 images, 3 × 256 × 256 tensors, and resized anime-face or glasses-image datasets.
What you can do after
Apply resolution-aware preprocessing via PyTorch and adjust batch size when larger image tensors exceed available memory.
How it connects
Links image generation with convolutional networks, tensor shapes, batch size, and GPU memory.

Also explained in

Compare how 4 books explain resolution →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Generative AI with PyTorch. The section links point to the parts of the book it draws on.