pipert.contrib.detection_demo.utils

Module Contents

Classes

FocalLoss

Functions

floatn(x, n=3)

load_classes(path)

model_info(model, report='summary')

labels_to_class_weights(labels, nc=80)

labels_to_image_weights(labels, nc=80, class_weights=np.ones(80))

coco_class_weights()

coco80_to_coco91_class()

weights_init_normal(m)

xyxy2xywh(x)

xywh2xyxy(x)

scale_coords(img1_shape, coords, img0_shape)

clip_coords(boxes, img_shape)

ap_per_class(tp, conf, pred_cls, target_cls)

Compute the average precision, given the recall and precision curves.

compute_ap(recall, precision)

Compute the average precision, given the recall and precision curves.

bbox_iou(box1, box2, x1y1x2y2=True, GIoU=False)

wh_iou(box1, box2)

compute_loss(p, targets, model)

build_targets(model, targets)

non_max_suppression(prediction, conf_thres=0.5, nms_thres=0.5)

Removes detections with lower object confidence score than ‘conf_thres’

get_yolo_layers(model)

print_model_biases(model)

strip_optimizer(f='weights/last.pt')

create_backbone(f='weights/last.pt')

coco_class_count(path='../coco/labels/train2014/')

coco_only_people(path='../coco/labels/val2014/')

select_best_evolve(path='evolve*.txt')

coco_single_class_labels(path='../coco/labels/train2014/', label_class=43)

print_mutation(hyp, results, bucket='')

fitness(x)

plot_one_box(x, img, color=None, label=None, line_thickness=None)

plot_wh_methods()

plot_images(imgs, targets, paths=None, fname='images.jpg')

plot_test_txt()

plot_targets_txt()

plot_evolution_results(hyp)

plot_results(start=0, stop=0)

plot_results_overlay(start=0, stop=0)

version_to_tuple(version)

pipert.contrib.detection_demo.utils.floatn(x, n=3)[source]
pipert.contrib.detection_demo.utils.load_classes(path)[source]
pipert.contrib.detection_demo.utils.model_info(model, report='summary')[source]
pipert.contrib.detection_demo.utils.labels_to_class_weights(labels, nc=80)[source]
pipert.contrib.detection_demo.utils.labels_to_image_weights(labels, nc=80, class_weights=np.ones(80))[source]
pipert.contrib.detection_demo.utils.coco_class_weights()[source]
pipert.contrib.detection_demo.utils.coco80_to_coco91_class()[source]
pipert.contrib.detection_demo.utils.weights_init_normal(m)[source]
pipert.contrib.detection_demo.utils.xyxy2xywh(x)[source]
pipert.contrib.detection_demo.utils.xywh2xyxy(x)[source]
pipert.contrib.detection_demo.utils.scale_coords(img1_shape, coords, img0_shape)[source]
pipert.contrib.detection_demo.utils.clip_coords(boxes, img_shape)[source]
pipert.contrib.detection_demo.utils.ap_per_class(tp, conf, pred_cls, target_cls)[source]

Compute the average precision, given the recall and precision curves. Source: https://github.com/rafaelpadilla/Object-Detection-Metrics. # Arguments

tp: True positives (list). conf: Objectness value from 0-1 (list). pred_cls: Predicted object classes (list). target_cls: True object classes (list).

# Returns

The average precision as computed in py-faster-rcnn.

pipert.contrib.detection_demo.utils.compute_ap(recall, precision)[source]

Compute the average precision, given the recall and precision curves. Source: https://github.com/rbgirshick/py-faster-rcnn. # Arguments

recall: The recall curve (list). precision: The precision curve (list).

# Returns

The average precision as computed in py-faster-rcnn.

pipert.contrib.detection_demo.utils.bbox_iou(box1, box2, x1y1x2y2=True, GIoU=False)[source]
pipert.contrib.detection_demo.utils.wh_iou(box1, box2)[source]
class pipert.contrib.detection_demo.utils.FocalLoss(loss_fcn, gamma=0.5, alpha=1, reduction='mean')[source]

Bases: torch.nn.Module

forward(self, input, target)[source]
pipert.contrib.detection_demo.utils.compute_loss(p, targets, model)[source]
pipert.contrib.detection_demo.utils.build_targets(model, targets)[source]
pipert.contrib.detection_demo.utils.non_max_suppression(prediction, conf_thres=0.5, nms_thres=0.5)[source]

Removes detections with lower object confidence score than ‘conf_thres’ Non-Maximum Suppression to further filter detections. Returns detections with shape:

(x1, y1, x2, y2, object_conf, class_conf, class)

pipert.contrib.detection_demo.utils.get_yolo_layers(model)[source]
pipert.contrib.detection_demo.utils.print_model_biases(model)[source]
pipert.contrib.detection_demo.utils.strip_optimizer(f='weights/last.pt')[source]
pipert.contrib.detection_demo.utils.create_backbone(f='weights/last.pt')[source]
pipert.contrib.detection_demo.utils.coco_class_count(path='../coco/labels/train2014/')[source]
pipert.contrib.detection_demo.utils.coco_only_people(path='../coco/labels/val2014/')[source]
pipert.contrib.detection_demo.utils.select_best_evolve(path='evolve*.txt')[source]
pipert.contrib.detection_demo.utils.coco_single_class_labels(path='../coco/labels/train2014/', label_class=43)[source]
pipert.contrib.detection_demo.utils.print_mutation(hyp, results, bucket='')[source]
pipert.contrib.detection_demo.utils.fitness(x)[source]
pipert.contrib.detection_demo.utils.plot_one_box(x, img, color=None, label=None, line_thickness=None)[source]
pipert.contrib.detection_demo.utils.plot_wh_methods()[source]
pipert.contrib.detection_demo.utils.plot_images(imgs, targets, paths=None, fname='images.jpg')[source]
pipert.contrib.detection_demo.utils.plot_test_txt()[source]
pipert.contrib.detection_demo.utils.plot_targets_txt()[source]
pipert.contrib.detection_demo.utils.plot_evolution_results(hyp)[source]
pipert.contrib.detection_demo.utils.plot_results(start=0, stop=0)[source]
pipert.contrib.detection_demo.utils.plot_results_overlay(start=0, stop=0)[source]
pipert.contrib.detection_demo.utils.version_to_tuple(version)[source]