liveBook · Manning

Fine-tuning dataset

As explained in Deep Learning with PyTorch, Second Edition

A dataset assembled specifically to adapt a pretrained model to a new task or labeling scheme.

A fine-tuning dataset adapts a pretrained model to a new task or labeling scheme. For CT segmentation, it pairs CT scan slices with nodule masks so a lightweight model can learn automatic segmentation without prompts. section 15.6.3

A practical fine-tuning dataset includes:

  • Input images, such as two-dimensional CT scan slices. section 15.6.3 section 15.6.2
  • Target labels, such as masks identifying the nodules to segment. section 15.6.3
  • Metadata linking image files and masks with information such as series identifiers and candidate locations. section 15.6.3
  • A clear storage arrangement, such as separate folders for CT images and masks. section 15.6.3

Generating a CT segmentation dataset

A pretrained SAM model receives a CT slice and a point marking a candidate nodule, then generates a mask. The CT slice and mask become a training pair for fine-tuning SegFormer. This produces a cheaper alternative to manually annotating every scan. section 15.6.3

Listing 15.7 Setting up directory structure for our new dataset
fine_tuning_dir = "data-unversioned/part2/fine-tuning/dataset"
ct_folder = f"{fine_tuning_dir}/ct"
mask_folder = f"{fine_tuning_dir}/mask"

Shows the compact directory layout used for CT images and masks. section 15.6.3

How Deep Learning with PyTorch, Second Edition covers it

How deep it goes
Explains inputs, masks, metadata, folders, caching, generation, and dataset access, but leaves model training details for later.
Examples
Uses CT slices, SAM-generated nodule masks, separate image and mask folders, metadata files, and SegFormer training pairs.
What it assumes
Assumes access to CT data and candidate coordinates while teaching slice extraction, mask generation, storage, and metadata linkage.
What you can do after
Build it from scratch by extracting CT slices, generating masks, organizing files, and exposing paired metadata through a dataset class.
How it connects
Connects pretrained models, image masks, semantic segmentation, object detection, CT scans, metadata, and dataset caching.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with PyTorch, Second Edition. The section links point to the parts of the book it draws on.