discopat.nn_training.torch_detection_utils package
Submodules
discopat.nn_training.torch_detection_utils.coco_eval module
- class discopat.nn_training.torch_detection_utils.coco_eval.COCOevalIoMean(cocoGt=None, cocoDt=None, iouType='segm')[source]
Bases:
COCOevalReplace IoU by IoMean.
- class discopat.nn_training.torch_detection_utils.coco_eval.CocoEvaluator(coco_gt, iou_types)[source]
Bases:
object
discopat.nn_training.torch_detection_utils.coco_utils module
- class discopat.nn_training.torch_detection_utils.coco_utils.CocoDetection(img_folder, ann_file, transforms)[source]
Bases:
CocoDetection
- class discopat.nn_training.torch_detection_utils.coco_utils.ConvertCocoPolysToMask[source]
Bases:
object
- discopat.nn_training.torch_detection_utils.coco_utils.convert_coco_poly_to_mask(segmentations, height, width)[source]
discopat.nn_training.torch_detection_utils.engine module
discopat.nn_training.torch_detection_utils.transforms module
- class discopat.nn_training.torch_detection_utils.transforms.Compose(transforms)[source]
Bases:
object
- class discopat.nn_training.torch_detection_utils.transforms.FixedSizeCrop(size, fill=0, padding_mode='constant')[source]
Bases:
Module- forward(img, target=None)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class discopat.nn_training.torch_detection_utils.transforms.PILToTensor(*args, **kwargs)[source]
Bases:
Module- forward(image, target=None)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Parameters:
image (Tensor)
target (Dict[str, Tensor] | None)
- Return type:
Tuple[Tensor, Dict[str, Tensor] | None]
- class discopat.nn_training.torch_detection_utils.transforms.RandomHorizontalFlip(p=0.5)[source]
Bases:
RandomHorizontalFlip
- class discopat.nn_training.torch_detection_utils.transforms.RandomIoUCrop(min_scale=0.3, max_scale=1.0, min_aspect_ratio=0.5, max_aspect_ratio=2.0, sampler_options=None, trials=40)[source]
Bases:
Module- Parameters:
min_scale (float)
max_scale (float)
min_aspect_ratio (float)
max_aspect_ratio (float)
sampler_options (List[float] | None)
trials (int)
- forward(image, target=None)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Parameters:
image (Tensor)
target (Dict[str, Tensor] | None)
- Return type:
Tuple[Tensor, Dict[str, Tensor] | None]
- class discopat.nn_training.torch_detection_utils.transforms.RandomPhotometricDistort(contrast=(0.5, 1.5), saturation=(0.5, 1.5), hue=(-0.05, 0.05), brightness=(0.875, 1.125), p=0.5)[source]
Bases:
Module- Parameters:
contrast (Tuple[float, float])
saturation (Tuple[float, float])
hue (Tuple[float, float])
brightness (Tuple[float, float])
p (float)
- forward(image, target=None)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Parameters:
image (Tensor)
target (Dict[str, Tensor] | None)
- Return type:
Tuple[Tensor, Dict[str, Tensor] | None]
- class discopat.nn_training.torch_detection_utils.transforms.RandomShortestSize(min_size, max_size, interpolation=InterpolationMode.BILINEAR)[source]
Bases:
Module- Parameters:
min_size (List[int] | Tuple[int] | int)
max_size (int)
interpolation (InterpolationMode)
- forward(image, target=None)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Parameters:
image (Tensor)
target (Dict[str, Tensor] | None)
- Return type:
Tuple[Tensor, Dict[str, Tensor] | None]
- class discopat.nn_training.torch_detection_utils.transforms.RandomZoomOut(fill=None, side_range=(1.0, 4.0), p=0.5)[source]
Bases:
Module- Parameters:
fill (List[float] | None)
side_range (Tuple[float, float])
p (float)
- forward(image, target=None)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Parameters:
image (Tensor)
target (Dict[str, Tensor] | None)
- Return type:
Tuple[Tensor, Dict[str, Tensor] | None]
- class discopat.nn_training.torch_detection_utils.transforms.ScaleJitter(target_size, scale_range=(0.1, 2.0), interpolation=InterpolationMode.BILINEAR, antialias=True)[source]
Bases:
ModuleRandomly resizes the image and its bounding boxes within the specified scale range. The class implements the Scale Jitter augmentation as described in the paper “Simple Copy-Paste is a Strong Data Augmentation Method for Instance Segmentation”.
- Parameters:
target_size (tuple of ints) – The target size for the transform provided in (height, weight) format.
scale_range (tuple of ints) – scaling factor interval, e.g (a, b), then scale is randomly sampled from the range a <= scale <= b.
interpolation (InterpolationMode) – Desired interpolation enum defined by
torchvision.transforms.InterpolationMode. Default isInterpolationMode.BILINEAR.
- forward(image, target=None)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Parameters:
image (Tensor)
target (Dict[str, Tensor] | None)
- Return type:
Tuple[Tensor, Dict[str, Tensor] | None]
- class discopat.nn_training.torch_detection_utils.transforms.SimpleCopyPaste(blending=True, resize_interpolation=InterpolationMode.BILINEAR)[source]
Bases:
Module- forward(images, targets)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Parameters:
images (List[Tensor])
targets (List[Dict[str, Tensor]])
- Return type:
Tuple[List[Tensor], List[Dict[str, Tensor]]]
- class discopat.nn_training.torch_detection_utils.transforms.ToDtype(dtype, scale=False)[source]
Bases:
Module- Parameters:
dtype (dtype)
scale (bool)
- forward(image, target=None)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Parameters:
image (Tensor)
target (Dict[str, Tensor] | None)
- Return type:
Tuple[Tensor, Dict[str, Tensor] | None]
discopat.nn_training.torch_detection_utils.utils module
- class discopat.nn_training.torch_detection_utils.utils.MetricLogger(delimiter='\t')[source]
Bases:
object
- class discopat.nn_training.torch_detection_utils.utils.SmoothedValue(window_size=20, fmt=None)[source]
Bases:
objectTrack a series of values and provide access to smoothed values over a window or the global series average.
- property avg
- property global_avg
- property max
- property median
- property value
- discopat.nn_training.torch_detection_utils.utils.all_gather(data)[source]
Run all_gather on arbitrary picklable data (not necessarily tensors) :param data: any picklable object
- Returns:
list of data gathered from each rank
- Return type:
list[data]
- discopat.nn_training.torch_detection_utils.utils.reduce_dict(input_dict, average=True)[source]
- Parameters:
input_dict (dict) – all the values will be reduced
average (bool) – whether to do average or sum
Reduce the values in the dictionary from all processes so that all processes have the averaged results. Returns a dict with the same fields as input_dict, after reduction.