phenocam_snow.data

class PhenoCamImageDataset(img_dir, labels_file, transform=None)

PyTorch dataset for PhenoCam images.

__init__(img_dir, labels_file, transform=None)
Parameters:
  • img_dir (str) – The directory where all the images are contained.

  • labels_file (str) – The path of the labels file for the images in img_dir.

  • transform (torch.nn.Module|None) – The transform to apply to the images.

class PhenoCamDataModule(site_name, train_dir, train_labels, test_dir, test_labels, batch_size=16)

pytorch_lightning DataModule that wraps the PhenoCam image dataset class.

__init__(site_name, train_dir, train_labels, test_dir, test_labels, batch_size=16)
Parameters:
  • site_name (str) – The name of the target PhenoCam site.

  • train_dir (str) – The directory containing the training images.

  • train_labels (str) – The path to the training labels.

  • test_dir (str) – The directory containing the testing images.

  • test_labels (str) – The path to the testing labels.

  • batch_size (int) – The training batch size, defaults to 16.

get_categories()
Gets a list of the image categories, ordered according to their

integer encoding.

Returns:

A list of categories.

Return type:

List[str]

prepare_data(train_download_args=None, train_label_args=None, test_download_args=None, test_label_args=None)
Parameters:
  • train_download_args (Dict[Any]|None) – Arguments for downloading training images.

  • train_label_args (Dict[Any]|None) – Arguments for labeling training imags. Needs to have a key called “method” which has two valid values: “in noteobook” and “via subdir”. If the value is the former, then the other keys should match the arguments required by utils.label_images_in_notebook. Otherwise, the other keys should match the arguments required by utils.label_images_via_subdir.

  • test_download_args (Dict[Any]|None) – Arguments for downloading testing images.

  • test_label_args (Dict[Any]|None) – Argument for labeling testing imagse. See the description for train_label_args.

setup(stage=None)
Parameters:

stage (str|None) – If the stage if “fit”, the training data is split 70/30 into training and validation sets. The augmented transformation policy is applied to the images. If the stage is “test”, the testing dataset is loaded and the standard transformation is applied to the images. By default, all three datasets are loaded.