ez-frcnn.characterize
def characterize.get_subsampled_dataset(full_dataset, num_samples):
Returns a randomly subsampled subset of a given dataset.
Inputs
full_dataset (Dataset): A PyTorch-style dataset to sample from. num_samples (int): The number of samples to include in the returned subset.
Output
Subset: A torch.utils.data.Subset containing num_samples
randomly selected items
from the original dataset.
Source code in library/characterize.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
def characterize.get_mAP(dataloader, model, device):
Computes the mean Average Precision (mAP) for a given object detection model on a dataset.
Inputs
dataloader (DataLoader): A PyTorch DataLoader providing batches of images and targets. model (nn.Module): The object detection model to evaluate. device (torch.device): The device (CPU or GPU) on which to run the model.
Output
dict: A dictionary containing mAP metrics computed by torchmetrics.MeanAveragePrecision().
Source code in library/characterize.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
def characterize.run_experiment(full_train_dataset, valid_dataset, num_classes, BATCH_SIZE, NUM_EXPERIMENTS=5, EPOCHS_PER_EXPERIMENT=100, TRIALS_PER_EXPERIMENT=3):
Runs a series of training experiments with increasing amounts of training data to evaluate model performance.
Inputs
full_train_dataset (Dataset): The full training dataset to subsample from. valid_dataset (Dataset): The validation dataset used to compute validation mAP. num_classes (int): Number of object classes (including background if applicable). BATCH_SIZE (int): Batch size used for training and validation. NUM_EXPERIMENTS (int): Number of increasing training set sizes to evaluate. Default is 5. EPOCHS_PER_EXPERIMENT (int): Number of training epochs per experiment. Default is 100. TRIALS_PER_EXPERIMENT (int): Number of trials to average per training size. Default is 3.
Output
list: A list of tuples, each containing (num_samples, mean_mAP, std_mAP) for each experiment.
Source code in library/characterize.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|