face01lib.damo_yolo.damo_internal.utils package

Submodules

face01lib.damo_yolo.damo_internal.utils.boxes module

adjust_box_anns(bbox, scale_ratio, padw, padh, w_max, h_max)[ソース]
bboxes_iou(bboxes_a, bboxes_b, xyxy=True)[ソース]
filter_box(output, scale_range)[ソース]

output: (N, 5+class) shape

matrix_iou(a, b)[ソース]

return iou of a and b, numpy version for data augenmentation

postprocess(cls_scores, bbox_preds, num_classes, conf_thre=0.7, nms_thre=0.45, imgs=None)[ソース]
xyxy2cxcywh(bboxes)[ソース]
xyxy2xywh(bboxes)[ソース]

face01lib.damo_yolo.damo_internal.utils.checkpoint module

load_ckpt(model, ckpt)[ソース]
save_checkpoint(state, is_best, save_dir, model_name='')[ソース]

face01lib.damo_yolo.damo_internal.utils.debug_utils module

debug_input_vis(imgs, targets, ids, train_loader)[ソース]

face01lib.damo_yolo.damo_internal.utils.demo_utils module

face01lib.damo_yolo.damo_internal.utils.dist module

This file contains primitives for multi-gpu communication. This is useful when doing distributed training.

all_gather(data, group=None)[ソース]

Run all_gather on arbitrary picklable data (not necessarily tensors). :param data: any picklable object :param group: a torch process group. By default, will use a group which

contains all ranks on gloo backend.

戻り値:

list of data gathered from each rank

戻り値の型:

list[data]

gather(data, dst=0, group=None)[ソース]

Run gather on arbitrary picklable data (not necessarily tensors). :param data: any picklable object :param dst: destination rank :type dst: int :param group: a torch process group. By default, will use a group which

contains all ranks on gloo backend.

戻り値:

on dst, a list of data gathered from each rank. Otherwise,

an empty list.

戻り値の型:

list[data]

get_local_rank() int[ソース]
戻り値:

The rank of the current process within the local (per-machine) process group.

get_local_size() int[ソース]
戻り値:

The size of the per-machine process group, i.e. the number of processes per machine.

get_num_devices()[ソース]
get_rank() int[ソース]
get_world_size() int[ソース]
is_main_process() bool[ソース]
synchronize()[ソース]

Helper function to synchronize (barrier) among all processes when using distributed training

time_synchronized()[ソース]

pytorch-accurate time

wait_for_the_master(local_rank: int)[ソース]

Make all processes waiting for the master to do some task.

face01lib.damo_yolo.damo_internal.utils.imports module

import_file(module_name, file_path, make_importable=False)[ソース]

face01lib.damo_yolo.damo_internal.utils.logger module

class StreamToLoguru(level='INFO', caller_names=('apex', 'pycocotools'))[ソース]

ベースクラス: object

stream object that redirects writes to a logger instance.

flush()[ソース]
write(buf)[ソース]
get_caller_name(depth=0)[ソース]
パラメータ:
  • depth (int) -- Depth of caller conext, use 0 for caller depth.

  • value (Default) --

戻り値:

module name of the caller

戻り値の型:

str

redirect_sys_output(log_level='INFO')[ソース]
setup_logger(save_dir, distributed_rank=0, mode='a')[ソース]

setup logger for training and testing. :param save_dir: location to save log file :type save_dir: str :param distributed_rank: device rank when multi-gpu environment :type distributed_rank: int :param mode: log file write mode, append or override. default is a. :type mode: str

戻り値:

logger instance.

face01lib.damo_yolo.damo_internal.utils.metric module

class AverageMeter(window_size=50)[ソース]

ベースクラス: object

Track a series of values and provide access to smoothed values over a window or the global series average.

property avg
clear()[ソース]
property global_avg
property latest
property median
reset()[ソース]
property total
update(value)[ソース]
class MeterBuffer(window_size=20)[ソース]

ベースクラス: defaultdict

Computes and stores the average and current value

clear_meters()[ソース]
get_filtered_meter(filter_key='time')[ソース]
reset()[ソース]
update([E, ]**F) None.  Update D from dict/iterable E and F.[ソース]

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

get_total_and_free_memory_in_Mb(cuda_device)[ソース]
gpu_mem_usage()[ソース]

Compute the GPU memory usage for the current device (MB).

face01lib.damo_yolo.damo_internal.utils.model_utils module

fuse_conv_and_bn(conv, bn)[ソース]
fuse_model(model)[ソース]
get_model_info(model, tsize)[ソース]
make_divisible(v, divisor=8, min_value=None)[ソース]
replace_module(module, replaced_module_type, new_module_type, replace_func=None)[ソース]

Replace given type in module to a new type. mostly used in deploy.

パラメータ:
  • module (nn.Module) -- model to apply replace operation.

  • replaced_module_type (Type) -- module type to be replaced.

  • new_module_type (Type)

  • replace_func (function) -- python function to describe replace logic. Defalut value None.

戻り値:

module that already been replaced.

戻り値の型:

model (nn.Module)

face01lib.damo_yolo.damo_internal.utils.timer module

class Timer[ソース]

ベースクラス: object

add(time_diff)[ソース]
property average_time
avg_time_str()[ソース]
reset()[ソース]
tic()[ソース]
toc(average=True)[ソース]
get_time_str(time_diff)[ソース]

face01lib.damo_yolo.damo_internal.utils.visualize module

vis(img, boxes, scores, cls_ids, conf=0.5, class_names=None)[ソース]

Module contents