Inference
This page acts as the technical reference for the inference subpackage.
The inference subpackage provides functionality that can be used to measure a camera's linearity, create HDR images, linearize single images and compute quantitatively well-defined mean and uncertainty images from a stack of images or a video.
compute_hdr_image(dataloader, device, icrf_model=None, weight_fn=None, flat_field_dataset=None, gpu_transforms=None, dark_field_dataset=None)
Function for computing HDR merging of a set of images at different exposure times under stationary conditions. Uncertainty can be computed if the dataset is provided with PairedFrameSettings instances that include a path to an uncertainty image. Flat field correction can be performed if an FlatFieldArtefactMapDataset is provided and a matching artefact image is found. Similarly, a dark field correction can be performed with a DarkFieldArtefactMapDataset. Args: dataloader: DataLoader containing an ImageMapDataset instance, which should contain FrameSettings or PairedFrameSettings instances. device: the device to run the computations on. icrf_model: an optional ICRF model to use to linearize the images before merging. weight_fn: a weighting function that takes as input the batch of images. flat_field_dataset: a FlatFieldArtefactMapDataset for flat field correction. gpu_transforms: Optional transform operations to be performed on the image batch after moving the data to the desired device. dark_field_dataset: a DarkFieldArtefactMapDataset for dark field correction.
Returns:
Type | Description |
---|---|
tuple[Tensor, Tensor | None]
|
A tuple representing - the HDR image (tensor) - uncertainty of the HDR image (tensor or None). |
Source code in clair_torch/inference/hdr_merge.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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 91 92 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 |
|
compute_video_mean_and_std(dataloader, device, icrf_model=None)
Function for computing the mean and standard deviation of the frames in a given dataset of video files. All frames in all the videos are treated as belonging in the same dataset. Args: dataloader: a DataLoader containing a VideoIterableDataset, representing the dataset. device: torch device to run the computation on. icrf_model: an ICRF model to optionally linearize the pixel values before computing the mean and std.
Returns:
Type | Description |
---|---|
tuple[Tensor, Tensor]
|
The mean and standard deviations of the (possibly linearized) video frames in the dataset. |
Source code in clair_torch/inference/inferential_statistics.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
linearize_dataset_generator(dataloader, device, icrf_model, flatfield_dataset=None, gpu_transforms=None, dark_field_dataset=None)
Generator function to yield single linearized image and its possible associated uncertainty. Args: dataloader: Torch dataloader with custom collate function. device: the device on which to run the linearization. icrf_model: the ICRF model used to linearize the images. flatfield_dataset: An FlatFieldArtefactMapDataset, used to select the appropriate flat field correction image for each linearized image. gpu_transforms: transform operations to run on each image as the first thing in the process. dark_field_dataset: An DarkFieldArtefactMapDataset, used to select the appropriate dark field correction image for each linearized image.
Returns:
Type | Description |
---|---|
None
|
A generator object yielding a tuple of image, uncertainty image and metadata dictionary. |
Source code in clair_torch/inference/linearization.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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 91 92 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 |
|