PyTorch DataLoader Explained: Datasets, Batches, and Image Folders
PyTorch DataLoader explained: build a Dataset, batch and shuffle CIFAR-10, use transforms.v2, speed up with num_workers, and load your own image folder.
Tutorials of programming languages, frameworks, libraries, etc.
PyTorch DataLoader explained: build a Dataset, batch and shuffle CIFAR-10, use transforms.v2, speed up with num_workers, and load your own image folder.
PyTorch autograd explained: requires_grad, the computational graph, how backward() applies the chain rule, why zero_grad matters, and torch.no_grad.
Learn what a PyTorch tensor is: shape, dtype, device, indexing, view vs reshape, broadcasting, and how to turn images into N, C, H, W tensors and back.
Free PyTorch tutorial for 2026: install PyTorch 2.15, check your GPU, make your first tensor, and start building a tiny diffusion transformer from scratch.
In this tutorial, I will show you how to convert RGBA images to RGB images in the simplest ways using OpenCV (cv2) and Pillow (PIL). An RGBA image has 4 channels: red, green, blue, and alpha. The alpha channel stores how transparent each pixel is, while an RGB image only has the 3 color channels […]
This tutorial will show you how to read/open an image from a URL using OpenCV (cv2) and Pillow (PIL). Also, we will show you how to read the image from a URL with request headers. If you want to read them into Base64, you may read Image & Base64. 1. Read From a URL OpenCV […]
This tutorial will show you how to read an image file into base64 format, and convert an image to base64 format (and from base64 to an image) in OpenCV (cv2) and Pillow (PIL). Base64 is a format to represent binary data in text. This is widely used on the web and email to deliver data […]
This tutorial will show you how to warp/transform an image in OpenCV (cv2) and Pillow (PIL), using the perspective transformation technique. If you only need to move (translate) an image or rotate an image, there are simpler ways. OpenCV The vertices of transformation are as follows: Pillow Where pa is the four vertices in the current plane, […]
In this tutorial, you will learn how to rotate or translate/shift an image with a specified background color. For simple image rotation and translation, please read the previous tutorials: 1. Image Rotation Rotate 45 degrees counterclockwise with a background color RGB(0,0,0) (black). OpenCV Pillow 2. Image Translation Translate the image to the right by 10 […]
This tutorial will show you how to translate/shift an image along the x-axis and y-axis using OpenCV (cv2) and Pillow (PIL). OpenCV Translate the image to the right by 10 pixels and downward by 20 pixels. Pillow Translate the image to the right by 10 pixels and downward by 20 pixels. Note: pil_img.rotate(angle, translate) will do translation […]