103 files
972.9 KB
288.6k tokens
471 symbols
1 requests
Download .txt
Showing preview only (1,029K chars total). Download the full file or copy to clipboard to get everything.
Repository: SpursLipu/YOLOv3v4-ModelCompression-MultidatasetTraining-Multibackbone
Branch: master
Commit: 0202ec6be7d6
Files: 103
Total size: 972.9 KB

Directory structure:
gitextract_flko7qgo/

├── EagleEye_normal_prune.py
├── EagleEye_regular_prune.py
├── EagleEye_slim_prune.py
├── LICENSE
├── PTQ.py
├── README.md
├── cfg/
│   ├── yolov2/
│   │   ├── yolov2-hand.cfg
│   │   ├── yolov2-tiny-hand.cfg
│   │   ├── yolov2-tiny.cfg
│   │   └── yolov2.cfg
│   ├── yolov3/
│   │   ├── yolov3-UAV.cfg
│   │   ├── yolov3-asff.cfg
│   │   ├── yolov3-bdd100k.cfg
│   │   ├── yolov3-hand.cfg
│   │   ├── yolov3-onDIOR.cfg
│   │   ├── yolov3-screw.cfg
│   │   ├── yolov3-ship.cfg
│   │   ├── yolov3-spp-matrix.cfg
│   │   ├── yolov3-spp-pan-scale.cfg
│   │   ├── yolov3-spp.cfg
│   │   ├── yolov3-spp3.cfg
│   │   ├── yolov3-visdrone.cfg
│   │   └── yolov3.cfg
│   ├── yolov3-ghostnet/
│   │   └── yolov3-ghost-coco.cfg
│   ├── yolov3-mobilenet/
│   │   ├── yolov3-mobilenet-UAV.cfg
│   │   ├── yolov3-mobilenet-coco.cfg
│   │   ├── yolov3-mobilenet-hand.cfg
│   │   ├── yolov3-mobilenet-screw.cfg
│   │   └── yolov3-mobilenet-visdrone.cfg
│   ├── yolov3-singlechannel/
│   │   └── yolov3-singlechannel.cfg
│   ├── yolov3tiny/
│   │   ├── yolov3-tiny-UAV.cfg
│   │   ├── yolov3-tiny-hand.cfg
│   │   ├── yolov3-tiny-ship-one.cfg
│   │   ├── yolov3-tiny-ship.cfg
│   │   ├── yolov3-tiny.cfg
│   │   ├── yolov3-tiny3.cfg
│   │   ├── yolov3-tiny_bdd100k.cfg
│   │   ├── yolov3-tiny_onDIOR.cfg
│   │   └── yolov3-tiny_visdrone.cfg
│   ├── yolov3tiny-efficientnetB0/
│   │   └── yolov3tiny-efficientnetB0.cfg
│   ├── yolov3tiny-mobilenet-small/
│   │   ├── yolov3tiny-mobilenet-small-UAV.cfg
│   │   ├── yolov3tiny-mobilenet-small-coco.cfg
│   │   ├── yolov3tiny-mobilenet-small-screw.cfg
│   │   └── yolov3tiny-mobilenet-small-visdrone.cfg
│   ├── yolov4/
│   │   ├── yolov4-hand.cfg
│   │   ├── yolov4-relu.cfg
│   │   ├── yolov4-visdrone.cfg
│   │   └── yolov4.cfg
│   └── yolov4tiny/
│       └── yolov4-tiny.cfg
├── convert.py
├── convert_FPGA.py
├── convert_FPGA_2.py
├── data/
│   ├── UAV_Samples_label.data
│   ├── UAV_Samples_label.names
│   ├── bdd100k.data
│   ├── bdd100k.names
│   ├── coco.names
│   ├── coco2014.data
│   ├── coco2017.data
│   ├── dior.data
│   ├── dior.names
│   ├── get_coco2014.sh
│   ├── get_coco2017.sh
│   ├── oxfordhand.data
│   ├── oxfordhand.names
│   ├── screw.data
│   ├── screw.names
│   ├── trainset.data
│   ├── trainset.names
│   ├── visdrone.data
│   └── visdrone.names
├── detect.py
├── info.py
├── layer_channel_prune.py
├── layer_channel_regular_prune.py
├── layer_prune.py
├── models.py
├── normal_prune.py
├── regular_prune.py
├── requirements.txt
├── shortcut_prune.py
├── slim_prune.py
├── test.py
├── train.py
├── utils/
│   ├── __init__.py
│   ├── adabound.py
│   ├── datasets.py
│   ├── gcp.sh
│   ├── google_utils.py
│   ├── layers.py
│   ├── output_upsample.py
│   ├── parse_config.py
│   ├── prune_utils.py
│   ├── quantized/
│   │   ├── __init__.py
│   │   ├── quantized_TPSQ.py
│   │   ├── quantized_dorefa.py
│   │   ├── quantized_google.py
│   │   ├── quantized_lowbit.py
│   │   ├── quantized_ptq.py
│   │   └── quantized_ptq_cos.py
│   ├── torch_utils.py
│   └── utils.py
└── weights/
    └── pretrain_weights/
        └── download_yolov3_weights.sh

================================================
FILE CONTENTS
================================================

================================================
FILE: EagleEye_normal_prune.py
================================================
from sys import float_repr_style
from models import *
from utils.utils import *
from utils.prune_utils import *
from utils.datasets import *
import os
import test
import argparse
from thop import profile
# from thop import profile
# from distiller.model_summaries import model_performance_summary

def obtain_avg_forward_time(input, model, repeat=200):
    model.eval()
    start = time.time()
    with torch.no_grad():
        for i in range(repeat):
            output = model(input)
    avg_infer_time = (time.time() - start) / repeat

    return avg_infer_time, output


def obtain_filters_mask(model, CBL_idx, prune_idx, idx_mask):
    pruned = 0
    total = 0
    num_filters = []
    filters_mask = []
    # CBL_idx存储的是所有带BN的卷积层(YOLO层的前一层卷积层是不带BN的)
    for idx in CBL_idx:
        bn_module = model.module_list[idx][1]
        if idx in prune_idx:
            mask = idx_mask[idx]
            # mask = obtain_bn_mask(bn_module, thre).cpu().numpy()
            remain = int(mask.sum())
            pruned = pruned + mask.shape[0] - remain

            if remain == 0:
                print("Channels would be all pruned!")
                raise Exception

            # print(f'layer index: {idx:>3d} \t total channel: {mask.shape[0]:>4d} \t '
            #       f'remaining channel: {remain:>4d}')
        else:
            mask = torch.ones(bn_module.weight.data.shape)
            remain = mask.shape[0]

        total += mask.shape[0]
        num_filters.append(remain)
        filters_mask.append(mask.clone())

    # 因此,这里求出的prune_ratio,需要裁剪的α参数/cbl_idx中所有的α参数
    # prune_ratio = pruned / total
    # print(f'Prune channels: {pruned}\tPrune ratio: {prune_ratio:.3f}')

    return num_filters, filters_mask


def obtain_l1_mask(conv_module, random_rate):
    w_copy = conv_module.weight.data.abs().clone()
    w_copy = torch.sum(w_copy, dim=(1, 2, 3))
    length = w_copy.cpu().numpy().shape[0]
    num_retain = int(length * (1 - random_rate))
    if num_retain == 0:
        num_retain = 1
    _, y = torch.topk(w_copy, num_retain)
    mask = torch.zeros(length, dtype=torch.float32).to(w_copy.device)
    mask[y] = 1

    return mask

#macs = flops / 2
def performance_summary(model, opt=None, prefix=""):
    macs, _ = profile(model, inputs=(torch.zeros(1, 3, 480, 640).to(device),), verbose=False)
    return macs


def rand_prune_and_eval(model, min_rate, max_rate):
    while True:
        model_copy = deepcopy(model)
        remain_num = 0
        idx_new = dict()
        for idx in prune_idx:
            # bn_module = model_copy.module_list[idx][1]
            conv_module = model_copy.module_list[idx][0]

            random_rate = (max_rate - min_rate) * (np.random.rand(1)) + min_rate
            mask = obtain_l1_mask(conv_module, random_rate)

            idx_new[idx] = mask
            remain_num += int(mask.sum())
            conv_module.weight.data = conv_module.weight.data.permute(1, 2, 3, 0).mul(mask).float().permute(3, 0, 1, 2)
            # bn_module.weight.data.mul_(mask)

        # ---------------
        num_filters, filters_mask = obtain_filters_mask(model_copy, CBL_idx, prune_idx, idx_new)
        CBLidx2mask = {idx: mask for idx, mask in zip(CBL_idx, filters_mask)}

        compact_module_defs = deepcopy(model.module_defs)
        for idx, num in zip(CBL_idx, num_filters):
            assert compact_module_defs[idx]['type'] == 'convolutional'
            compact_module_defs[idx]['filters'] = str(num)
        compact_model = Darknet([model.hyperparams.copy()] + compact_module_defs).to(device)
        current_parameters = obtain_num_parameters(compact_model)
        # print(current_parameters/origin_nparameters, end=';')
        current_macs = performance_summary(compact_model)
        # if current_parameters / origin_nparameters > remain_ratio + delta or current_parameters / origin_nparameters < remain_ratio - delta:
        # macs = flops/2
        if current_macs / origin_macs > remain_ratio + delta or current_macs / origin_macs < remain_ratio - delta:
            # print('missing')
            model_copy.cpu()
            compact_model.cpu()
            torch.cuda.empty_cache()
            continue

        print("yes---")

        for i in CBLidx2mask:
            CBLidx2mask[i] = CBLidx2mask[i].clone().cpu().numpy()
        pruned_model = prune_model_keep_size_forEagleEye(model, prune_idx, CBLidx2mask)
        init_weights_from_loose_model(compact_model, pruned_model, CBL_idx, Conv_idx, CBLidx2mask)

        compact_model.train()
        with torch.no_grad():
            for batch_i, (imgs, targets, paths, shapes) in enumerate(tqdm(dataloader)):
                imgs = imgs.cuda().float() / 255.0
                compact_model(imgs)
                if batch_i > steps:
                    break
        del model_copy
        torch.cuda.empty_cache()
        break
    return compact_module_defs, current_parameters, compact_model


if __name__ == '__main__':

    parser = argparse.ArgumentParser()
    parser.add_argument('--cfg', type=str, default='cfg/yolov3/yolov3.cfg', help='cfg file path')
    parser.add_argument('--data', type=str, default='data/coco2017.data', help='*.data file path')
    parser.add_argument('--weights', type=str, default='weights/pretrain_weights/yolov3.weights',
                        help='sparse model weights')
    parser.add_argument('--percent', type=float, default=0.5, help='global channel prune percent')
    parser.add_argument('--delta', type=float, default=0.05, help='delta')
    parser.add_argument('--img-size', type=int, default=416, help='inference size (pixels)')
    parser.add_argument('--batch-size', type=int, default=16, help='batch-size')
    parser.add_argument('--number', type=int, default=200, help='number of subnetwork')
    opt = parser.parse_args()
    print(opt)

    t0 = time.time()
    remain_ratio = 1 - opt.percent
    number = opt.number
    img_size = opt.img_size
    batch_size = opt.batch_size
    delta = opt.delta

    hyp = {'giou': 3.54,  # giou loss gain
           'cls': 37.4,  # cls loss gain
           'cls_pw': 1.0,  # cls BCELoss positive_weight
           'obj': 64.3,  # obj loss gain (*=img_size/320 if img_size != 320)
           'obj_pw': 1.0,  # obj BCELoss positive_weight
           'iou_t': 0.20,  # iou training threshold
           'lr0': 0.01,  # initial learning rate (SGD=5E-3, Adam=5E-4)
           'lrf': 0.0005,  # final learning rate (with cos scheduler)
           'momentum': 0.937,  # SGD momentum
           'weight_decay': 0.0005,  # optimizer weight decay
           'fl_gamma': 0.0,  # focal loss gamma (efficientDet default is gamma=1.5)
           'hsv_h': 0.0138,  # image HSV-Hue augmentation (fraction)
           'hsv_s': 0.678,  # image HSV-Saturation augmentation (fraction)
           'hsv_v': 0.36,  # image HSV-Value augmentation (fraction)
           'degrees': 1.98 * 0,  # image rotation (+/- deg)
           'translate': 0.05 * 0,  # image translation (+/- fraction)
           'scale': 0.05 * 0,  # image scale (+/- gain)
           'shear': 0.641 * 0}  # image shear (+/- deg)

    device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    model = Darknet(opt.cfg).to(device)

    if opt.weights:
        if opt.weights.endswith(".pt"):
            model.load_state_dict(torch.load(opt.weights, map_location=device)['model'])
        else:
            _ = load_darknet_weights(model, opt.weights)

    data_config = parse_data_cfg(opt.data)

    valid_path = data_config["valid"]
    train_path = data_config["train"]
    class_names = load_classes(data_config["names"])
    steps = math.ceil((len(open(train_path).readlines()) / batch_size) * 0.1)

    obtain_num_parameters = lambda model: sum([param.nelement() for param in model.parameters()])

    dataset = LoadImagesAndLabels(train_path,
                                  img_size,
                                  batch_size,
                                  augment=True,
                                  hyp=hyp,  # augmentation hyperparameters
                                  rect=False,  # rectangular training
                                  cache_images=False)

    dataloader = torch.utils.data.DataLoader(dataset,
                                             batch_size=batch_size,
                                             num_workers=min([os.cpu_count(), batch_size, 16]),
                                             shuffle=True,  # Shuffle=True unless rectangular training is used
                                             pin_memory=True,
                                             collate_fn=dataset.collate_fn)

    test_dataset = LoadImagesAndLabels(valid_path, img_size, batch_size,
                                       hyp=hyp,
                                       rect=True,
                                       cache_images=False)
    testloader = torch.utils.data.DataLoader(test_dataset,
                                             batch_size=batch_size,
                                             num_workers=min([os.cpu_count(), batch_size, 8]),
                                             shuffle=False,
                                             pin_memory=True,
                                             collate_fn=test_dataset.collate_fn)

    with torch.no_grad():
        origin_model_metric = test.test(opt.cfg,
                                        opt.data,
                                        batch_size=batch_size,
                                        imgsz=img_size,
                                        model=model,
                                        dataloader=testloader,
                                        rank=-1,
                                        plot=False)
    origin_nparameters = obtain_num_parameters(model)
    origin_macs = performance_summary(model)

    CBL_idx, Conv_idx, prune_idx = parse_module_defs(model.module_defs)

    print("-------------------------------------------------------")

    max_mAP = 0
    for i in range(number):
        compact_module_defs, current_parameters, compact_model = rand_prune_and_eval(model, 0, 1)
        with torch.no_grad():
            # 防止随机生成的较差的模型撑爆显存,增大nmsconf阈值
            mAP = test.test(opt.cfg,
                            opt.data,
                            batch_size=batch_size,
                            imgsz=img_size,
                            conf_thres=0.1,
                            model=compact_model,
                            dataloader=testloader,
                            rank=-1,
                            plot=False)[0][2]
        print('candidate: ' + str(i), end=" ")
        print('remain_ratio: ' + str(current_parameters / origin_nparameters))
        print(f'mAP of the pruned model is {mAP:.4f}')
        if mAP > max_mAP:
            max_mAP = mAP
            compact_model_winnner = deepcopy(compact_model)
            cfg_name = 'cfg_backup/' + str(i) + '.cfg'
            if not os.path.isdir('cfg_backup/'):
                os.makedirs('cfg_backup/')
            pruned_cfg_file = write_cfg(cfg_name, [model.hyperparams.copy()] + compact_module_defs)
        del compact_model
        torch.cuda.empty_cache()
    # 获得原始模型的module_defs,并修改该defs中的卷积核数量
    compact_module_defs = deepcopy(compact_model_winnner.module_defs)

    compact_nparameters = obtain_num_parameters(compact_model_winnner)

    compact_macs =  performance_summary(compact_model_winnner)
    compact_flops =  compact_macs*2 / 1024**3
    origin_flops = origin_macs*2 / 1024**3

    random_input = torch.rand((16, 3, 416, 416)).to(device)

    pruned_forward_time, pruned_output = obtain_avg_forward_time(random_input, model)
    compact_forward_time, compact_output = obtain_avg_forward_time(random_input, compact_model_winnner)

    # 在测试集上测试剪枝后的模型, 并统计模型的参数数量
    with torch.no_grad():
        compact_model_metric = test.test(opt.cfg,
                                         opt.data,
                                         batch_size=batch_size,
                                         imgsz=img_size,
                                         model=compact_model_winnner,
                                         dataloader=testloader,
                                         rank=-1,
                                         plot=False)

    # 比较剪枝前后参数数量的变化、指标性能的变化
    metric_table = [
        ["Metric", "Before", "After"],
        ["mAP", f'{origin_model_metric[1].mean():.6f}', f'{compact_model_metric[1].mean():.6f}'],
        ["Parameters", f"{origin_nparameters}", f"{compact_nparameters}"],
        ["GFLOPs",f"{origin_flops}",f"{compact_flops}"],
        ["Inference", f'{pruned_forward_time:.4f}', f'{compact_forward_time:.4f}']
    ]
    print(AsciiTable(metric_table).table)

    # 生成剪枝后的cfg文件并保存模型
    pruned_cfg_name = 'cfg/rand-normal_' + str(remain_ratio) + '_' + str(number) + '/' + 'rand-normal_-' + str(
        remain_ratio) + '_' + str(number) + '.cfg'
    # 创建存储目录
    dir_name = 'cfg/rand-normal_' + str(remain_ratio) + '_' + str(number) + '/'
    if not os.path.isdir(dir_name):
        os.makedirs(dir_name)

    # 由于原始的compact_module_defs将anchor从字符串变为了数组,因此这里将anchors重新变为字符串
    file = open(opt.cfg, 'r')
    lines = file.read().split('\n')
    for line in lines:
        if line.split(' = ')[0] == 'anchors':
            anchor = line.split(' = ')[1]
            break
        if line.split('=')[0] == 'anchors':
            anchor = line.split('=')[1]
            break
    file.close()
    for item in compact_module_defs:
        if item['type'] == 'shortcut':
            item['from'] = str(item['from'][0])
        elif item['type'] == 'route':
            item['layers'] = ",".join('%s' % i for i in item['layers'])
        elif item['type'] == 'yolo':
            item['mask'] = ",".join('%s' % i for i in item['mask'])
            item['anchors'] = anchor
    pruned_cfg_file = write_cfg(pruned_cfg_name, [model.hyperparams.copy()] + compact_module_defs)
    print(f'Config file has been saved: {pruned_cfg_file}')
    weights_dir_name = dir_name.replace('cfg', 'weights')
    if not os.path.isdir(weights_dir_name):
        os.makedirs(weights_dir_name)
    compact_model_name = weights_dir_name + 'rand-normal_' + str(remain_ratio) + '_' + str(number) + '.weights'

    save_weights(compact_model_winnner, path=compact_model_name)
    print(f'Compact model has been saved: {compact_model_name}')
    print('%g sub networks completed in %.3f hours.\n' % (number, (time.time() - t0) / 3600))


================================================
FILE: EagleEye_regular_prune.py
================================================
from models import *
from utils.utils import *
from utils.prune_utils import *
from utils.datasets import *
import os
import test
import argparse
from thop import profile

def obtain_avg_forward_time(input, model, repeat=200):
    model.eval()
    start = time.time()
    with torch.no_grad():
        for i in range(repeat):
            output = model(input)
    avg_infer_time = (time.time() - start) / repeat

    return avg_infer_time, output


def obtain_filters_mask(model, CBL_idx, prune_idx, idx_mask):
    pruned = 0
    total = 0
    num_filters = []
    filters_mask = []
    # CBL_idx存储的是所有带BN的卷积层(YOLO层的前一层卷积层是不带BN的)
    for idx in CBL_idx:
        bn_module = model.module_list[idx][1]
        if idx in prune_idx:
            mask = idx_mask[idx]
            # mask = obtain_bn_mask(bn_module, thre).cpu().numpy()
            remain = int(mask.sum())
            pruned = pruned + mask.shape[0] - remain

            if remain == 0:
                print("Channels would be all pruned!")
                raise Exception


        else:
            mask = torch.ones(bn_module.weight.data.shape)
            remain = mask.shape[0]

        total += mask.shape[0]
        num_filters.append(remain)
        filters_mask.append(mask.clone())

    return num_filters, filters_mask



def obtain_l1_mask(conv_module, random_rate):
    w_copy = conv_module.weight.data.abs().clone()
    w_copy = torch.sum(w_copy, dim=(1, 2, 3))
    length = w_copy.cpu().numpy().shape[0]
    num_retain = int(length * (1 - random_rate))
    num_retain = get_nearest_multiple(num_retain,channel_base)
    if num_retain > length:
        num_retain = length
    if num_retain == 0:
        num_retain = channel_base
    _, y = torch.topk(w_copy, num_retain)
    mask = torch.zeros(length, dtype=torch.float32).to(w_copy.device)
    mask[y] = 1
    return mask

#macs = flops / 2
def performance_summary(model, opt=None, prefix=""):
    macs, _ = profile(model, inputs=(torch.zeros(1, 3, 480, 640).to(device),), verbose=False)
    return macs

def rand_prune_and_eval(model, min_rate, max_rate):
    while True:
        model_copy = deepcopy(model)
        remain_num = 0
        idx_new = dict()
        for idx in prune_idx:
            # bn_module = model_copy.module_list[idx][1]
            conv_module = model_copy.module_list[idx][0]
            random_rate = (max_rate - min_rate) * (np.random.rand(1)) + min_rate
            mask = obtain_l1_mask(conv_module, random_rate)
            idx_new[idx] = mask
            remain_num += int(mask.sum())
            conv_module.weight.data = conv_module.weight.data.permute(1, 2, 3, 0).mul(mask).float().permute(3, 0, 1, 2)
            # bn_module.weight.data.mul_(mask)

        # ---------------
        num_filters, filters_mask = obtain_filters_mask(model_copy, CBL_idx, prune_idx, idx_new)
        CBLidx2mask = {idx: mask for idx, mask in zip(CBL_idx, filters_mask)}
        CBLidx2filters = {idx: filters for idx, filters in zip(CBL_idx, num_filters)}
        compact_module_defs = deepcopy(model.module_defs)
        for i in model_copy.module_defs:
            if i['type'] == 'shortcut':
                i['is_access'] = False
        merge_mask(model_copy, CBLidx2mask, CBLidx2filters, base=channel_base)

        for idx, num in CBLidx2filters.items():
            #num = get_nearest_multiple(num,channel_base)
            assert compact_module_defs[idx]['type'] == 'convolutional'
            compact_module_defs[idx]['filters'] = str(num)
        compact_model = Darknet([model.hyperparams.copy()] + compact_module_defs).to(device)
        current_parameters = obtain_num_parameters(compact_model)
        # print(current_parameters/origin_nparameters, end=';')
        current_macs = performance_summary(compact_model)
        # macs = flops/2
        if current_macs / origin_macs > remain_ratio + delta or current_macs / origin_macs < remain_ratio - delta:
            # print('missing')
            del model_copy
            del compact_model
            torch.cuda.empty_cache()
            continue
        print("yes---")

        for i in CBLidx2mask:
            CBLidx2mask[i] = CBLidx2mask[i].clone().cpu().numpy()
        pruned_model = prune_model_keep_size_forEagleEye(model, prune_idx, CBLidx2mask)
        init_weights_from_loose_model(compact_model, pruned_model, CBL_idx, Conv_idx, CBLidx2mask)
        compact_model.train()
        with torch.no_grad():
            for batch_i, (imgs, targets, paths, shapes) in enumerate(tqdm(dataloader)):
                imgs = imgs.cuda().float() / 255.0
                compact_model(imgs)
                if batch_i > steps:
                    break
        del model_copy
        torch.cuda.empty_cache()
        break
    return compact_module_defs, current_parameters, compact_model


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--cfg', type=str, default='cfg/yolov3/yolov3.cfg', help='cfg file path')
    parser.add_argument('--data', type=str, default='data/coco2017.data', help='*.data file path')
    parser.add_argument('--weights', type=str, default='weights/pretrain_weights/yolov3.weights',
                        help='sparse model weights')
    parser.add_argument('--percent', type=float, default=0.5, help='global channel prune percent')
    parser.add_argument('--delta', type=float, default=0.05, help='delta')
    parser.add_argument('--img-size', type=int, default=416, help='inference size (pixels)')
    parser.add_argument('--batch-size', type=int, default=16, help='batch-size')
    parser.add_argument('--number', type=int, default=200, help='number of subnetwork')
    parser.add_argument('--channel-base', type=int, default=8, help='channel of subnetwork is multiple of channel-base')
    opt = parser.parse_args()
    print(opt)

    t0 = time.time()
    remain_ratio = 1 - opt.percent
    number = opt.number
    img_size = opt.img_size
    batch_size = opt.batch_size
    delta = opt.delta
    channel_base = opt.channel_base
    hyp = {'giou': 3.54,  # giou loss gain
           'cls': 37.4,  # cls loss gain
           'cls_pw': 1.0,  # cls BCELoss positive_weight
           'obj': 64.3,  # obj loss gain (*=img_size/320 if img_size != 320)
           'obj_pw': 1.0,  # obj BCELoss positive_weight
           'iou_t': 0.20,  # iou training threshold
           'lr0': 0.01,  # initial learning rate (SGD=5E-3, Adam=5E-4)
           'lrf': 0.0005,  # final learning rate (with cos scheduler)
           'momentum': 0.937,  # SGD momentum
           'weight_decay': 0.0005,  # optimizer weight decay
           'fl_gamma': 0.0,  # focal loss gamma (efficientDet default is gamma=1.5)
           'hsv_h': 0.0138,  # image HSV-Hue augmentation (fraction)
           'hsv_s': 0.678,  # image HSV-Saturation augmentation (fraction)
           'hsv_v': 0.36,  # image HSV-Value augmentation (fraction)
           'degrees': 1.98 * 0,  # image rotation (+/- deg)
           'translate': 0.05 * 0,  # image translation (+/- fraction)
           'scale': 0.05 * 0,  # image scale (+/- gain)
           'shear': 0.641 * 0}  # image shear (+/- deg)

    device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    model = Darknet(opt.cfg).to(device)

    if opt.weights:
        if opt.weights.endswith(".pt"):
            model.load_state_dict(torch.load(opt.weights, map_location=device)['model'])
        else:
            _ = load_darknet_weights(model, opt.weights)

    data_config = parse_data_cfg(opt.data)

    valid_path = data_config["valid"]
    train_path = data_config["train"]
    class_names = load_classes(data_config["names"])
    steps = math.ceil((len(open(train_path).readlines()) / batch_size) * 0.1)

    obtain_num_parameters = lambda model: sum([param.nelement() for param in model.parameters()])

    dataset = LoadImagesAndLabels(train_path,
                                  img_size,
                                  batch_size,
                                  augment=True,
                                  hyp=hyp,  # augmentation hyperparameters
                                  rect=False,  # rectangular training
                                  cache_images=False)

    dataloader = torch.utils.data.DataLoader(dataset,
                                             batch_size=batch_size,
                                             num_workers=min([os.cpu_count(), batch_size, 16]),
                                             shuffle=True,  # Shuffle=True unless rectangular training is used
                                             pin_memory=True,
                                             collate_fn=dataset.collate_fn)

    test_dataset = LoadImagesAndLabels(valid_path, img_size, batch_size,
                                       hyp=hyp,
                                       rect=True,
                                       cache_images=False)
    testloader = torch.utils.data.DataLoader(test_dataset,
                                             batch_size=batch_size,
                                             num_workers=min([os.cpu_count(), batch_size, 8]),
                                             shuffle=False,
                                             pin_memory=True,
                                             collate_fn=test_dataset.collate_fn)
    with torch.no_grad():
        origin_model_metric = test.test(opt.cfg,
                                        opt.data,
                                        batch_size=batch_size,
                                        imgsz=img_size,
                                        model=model,
                                        dataloader=testloader,
                                        rank=-1,
                                        plot=False)
    origin_nparameters = obtain_num_parameters(model)
    origin_macs = performance_summary(model)

    CBL_idx, Conv_idx, prune_idx, _, _ = parse_module_defs2(model.module_defs)

    print("-------------------------------------------------------")

    max_mAP = 0
    for i in range(number):
        compact_module_defs, current_parameters, compact_model = rand_prune_and_eval(model, 0, 1)
        with torch.no_grad():
            # 防止随机生成的较差的模型撑爆显存,增大nmsconf阈值
            mAP = test.test(opt.cfg,
                            opt.data,
                            batch_size=batch_size,
                            imgsz=img_size,
                            conf_thres=0.1,
                            model=compact_model,
                            dataloader=testloader,
                            rank=-1,
                            plot=False)[0][2]

        print('candidate: ' + str(i), end=" ")
        print('remain_ratio: ' + str(current_parameters / origin_nparameters))
        print(f'mAP of the pruned model is {mAP:.4f}')
        if mAP > max_mAP:
            max_mAP = mAP
            compact_model_winnner = deepcopy(compact_model)
            cfg_name = 'cfg_backup/' + str(i) + '.cfg'
            if not os.path.isdir('cfg_backup/'):
                os.makedirs('cfg_backup/')
            pruned_cfg_file = write_cfg(cfg_name, [model.hyperparams.copy()] + compact_module_defs)
        del compact_model
        torch.cuda.empty_cache()
    # 获得原始模型的module_defs,并修改该defs中的卷积核数量
    compact_module_defs = deepcopy(compact_model_winnner.module_defs)
    compact_nparameters = obtain_num_parameters(compact_model_winnner)

    compact_macs =  performance_summary(compact_model_winnner)
    compact_flops =  compact_macs*2 / 1024**3
    origin_flops = origin_macs*2 / 1024**3

    random_input = torch.rand((16, 3, 416, 416)).to(device)

    pruned_forward_time, pruned_output = obtain_avg_forward_time(random_input, model)
    compact_forward_time, compact_output = obtain_avg_forward_time(random_input, compact_model_winnner)

    # 在测试集上测试剪枝后的模型, 并统计模型的参数数量
    with torch.no_grad():
        compact_model_metric = test.test(opt.cfg,
                                         opt.data,
                                         batch_size=batch_size,
                                         imgsz=img_size,
                                         model=compact_model_winnner,
                                         dataloader=testloader,
                                         rank=-1,
                                         plot=False)

    # 比较剪枝前后参数数量的变化、指标性能的变化
    metric_table = [
        ["Metric", "Before", "After"],
        ["mAP", f'{origin_model_metric[1].mean():.6f}', f'{compact_model_metric[1].mean():.6f}'],
        ["Parameters", f"{origin_nparameters}", f"{compact_nparameters}"],
        ["GFLOPs",f"{origin_flops}",f"{compact_flops}"],
        ["Inference", f'{pruned_forward_time:.4f}', f'{compact_forward_time:.4f}']
    ]
    print(AsciiTable(metric_table).table)

    # 生成剪枝后的cfg文件并保存模型
    pruned_cfg_name = 'cfg/rand-slim_' + str(remain_ratio) + '_' + str(number) + '/' + 'rand-slim_' + str(
        remain_ratio) + '_' + str(number) + '.cfg'
    # 创建存储目录
    dir_name = 'cfg/rand-slim_' + str(remain_ratio) + '_' + str(number) + '/'
    if not os.path.isdir(dir_name):
        os.makedirs(dir_name)

    # 由于原始的compact_module_defs将anchor从字符串变为了数组,因此这里将anchors重新变为字符串
    file = open(opt.cfg, 'r')
    lines = file.read().split('\n')
    for line in lines:
        if line.split(' = ')[0] == 'anchors':
            anchor = line.split(' = ')[1]
            break
        if line.split('=')[0] == 'anchors':
            anchor = line.split('=')[1]
            break
    file.close()
    for item in compact_module_defs:
        if item['type'] == 'shortcut':
            item['from'] = str(item['from'][0])
        elif item['type'] == 'route':
            item['layers'] = ",".join('%s' % i for i in item['layers'])
        elif item['type'] == 'yolo':
            item['mask'] = ",".join('%s' % i for i in item['mask'])
            item['anchors'] = anchor
    pruned_cfg_file = write_cfg(pruned_cfg_name, [model.hyperparams.copy()] + compact_module_defs)
    print(f'Config file has been saved: {pruned_cfg_file}')
    weights_dir_name = dir_name.replace('cfg', 'weights')
    if not os.path.isdir(weights_dir_name):
        os.makedirs(weights_dir_name)
    compact_model_name = weights_dir_name + 'rand-slim_' + str(remain_ratio) + '_' + str(number) + '.weights'

    save_weights(compact_model_winnner, path=compact_model_name)
    print(f'Compact model has been saved: {compact_model_name}')
    print('%g sub networks completed in %.3f hours.\n' % (number, (time.time() - t0) / 3600))


================================================
FILE: EagleEye_slim_prune.py
================================================
from models import *
from utils.utils import *
from utils.prune_utils import *
from utils.datasets import *
import os
import test
import argparse
from thop import profile


def obtain_avg_forward_time(input, model, repeat=200):
    model.eval()
    start = time.time()
    with torch.no_grad():
        for i in range(repeat):
            output = model(input)
    avg_infer_time = (time.time() - start) / repeat

    return avg_infer_time, output


def obtain_filters_mask(model, CBL_idx, prune_idx, idx_mask):
    pruned = 0
    total = 0
    num_filters = []
    filters_mask = []
    # CBL_idx存储的是所有带BN的卷积层(YOLO层的前一层卷积层是不带BN的)
    for idx in CBL_idx:
        bn_module = model.module_list[idx][1]
        if idx in prune_idx:
            mask = idx_mask[idx]
            # mask = obtain_bn_mask(bn_module, thre).cpu().numpy()
            remain = int(mask.sum())
            pruned = pruned + mask.shape[0] - remain

            if remain == 0:
                print("Channels would be all pruned!")
                raise Exception

        else:
            mask = torch.ones(bn_module.weight.data.shape)
            remain = mask.shape[0]

        total += mask.shape[0]
        num_filters.append(remain)
        filters_mask.append(mask.clone())

    return num_filters, filters_mask


def obtain_l1_mask(conv_module, random_rate):
    w_copy = conv_module.weight.data.abs().clone()
    w_copy = torch.sum(w_copy, dim=(1, 2, 3))
    length = w_copy.cpu().numpy().shape[0]
    num_retain = int(length * (1 - random_rate))
    if num_retain == 0:
        num_retain = 1
    _, y = torch.topk(w_copy, num_retain)
    mask = torch.zeros(length, dtype=torch.float32).to(w_copy.device)
    mask[y] = 1

    return mask

#macs = flops / 2
def performance_summary(model, opt=None, prefix=""):
    macs, _ = profile(model, inputs=(torch.zeros(1, 3, 480, 640).to(device),), verbose=False)
    return macs

def rand_prune_and_eval(model, min_rate, max_rate):
    while True:
        model_copy = deepcopy(model)
        remain_num = 0
        idx_new = dict()
        for idx in prune_idx:
            # bn_module = model_copy.module_list[idx][1]
            conv_module = model_copy.module_list[idx][0]

            random_rate = (max_rate - min_rate) * (np.random.rand(1)) + min_rate
            mask = obtain_l1_mask(conv_module, random_rate)

            idx_new[idx] = mask
            remain_num += int(mask.sum())
            conv_module.weight.data = conv_module.weight.data.permute(1, 2, 3, 0).mul(mask).float().permute(3, 0, 1, 2)
            # bn_module.weight.data.mul_(mask)

        # ---------------
        num_filters, filters_mask = obtain_filters_mask(model_copy, CBL_idx, prune_idx, idx_new)
        CBLidx2mask = {idx: mask for idx, mask in zip(CBL_idx, filters_mask)}
        CBLidx2filters = {idx: filters for idx, filters in zip(CBL_idx, num_filters)}
        compact_module_defs = deepcopy(model.module_defs)
        for i in model_copy.module_defs:
            if i['type'] == 'shortcut':
                i['is_access'] = False
        merge_mask(model_copy, CBLidx2mask, CBLidx2filters)

        for idx, num in CBLidx2filters.items():
            assert compact_module_defs[idx]['type'] == 'convolutional'
            compact_module_defs[idx]['filters'] = str(num)
        compact_model = Darknet([model.hyperparams.copy()] + compact_module_defs).to(device)
        current_parameters = obtain_num_parameters(compact_model)
        # print(current_parameters/origin_nparameters, end=';')
        current_macs = performance_summary(compact_model)
        # macs = flops/2
        if current_macs / origin_macs > remain_ratio + delta or current_macs / origin_macs < remain_ratio - delta:
            # print('missing')
            del model_copy
            del compact_model
            torch.cuda.empty_cache()
            continue
        print("yes---")

        for i in CBLidx2mask:
            CBLidx2mask[i] = CBLidx2mask[i].clone().cpu().numpy()
        pruned_model = prune_model_keep_size_forEagleEye(model, prune_idx, CBLidx2mask)
        init_weights_from_loose_model(compact_model, pruned_model, CBL_idx, Conv_idx, CBLidx2mask)
        compact_model.train()
        with torch.no_grad():
            for batch_i, (imgs, targets, paths, shapes) in enumerate(tqdm(dataloader)):
                imgs = imgs.cuda().float() / 255.0
                compact_model(imgs)
                if batch_i > steps:
                    break
        del model_copy
        torch.cuda.empty_cache()
        break
    return compact_module_defs, current_parameters, compact_model


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--cfg', type=str, default='cfg/yolov3/yolov3.cfg', help='cfg file path')
    parser.add_argument('--data', type=str, default='data/coco2017.data', help='*.data file path')
    parser.add_argument('--weights', type=str, default='weights/pretrain_weights/yolov3.weights',
                        help='sparse model weights')
    parser.add_argument('--percent', type=float, default=0.5, help='global channel prune percent')
    parser.add_argument('--delta', type=float, default=0.05, help='delta')
    parser.add_argument('--img-size', type=int, default=416, help='inference size (pixels)')
    parser.add_argument('--batch-size', type=int, default=16, help='batch-size')
    parser.add_argument('--number', type=int, default=200, help='number of subnetwork')
    opt = parser.parse_args()
    print(opt)

    t0 = time.time()
    remain_ratio = 1 - opt.percent
    number = opt.number
    img_size = opt.img_size
    batch_size = opt.batch_size
    delta = opt.delta

    hyp = {'giou': 3.54,  # giou loss gain
           'cls': 37.4,  # cls loss gain
           'cls_pw': 1.0,  # cls BCELoss positive_weight
           'obj': 64.3,  # obj loss gain (*=img_size/320 if img_size != 320)
           'obj_pw': 1.0,  # obj BCELoss positive_weight
           'iou_t': 0.20,  # iou training threshold
           'lr0': 0.01,  # initial learning rate (SGD=5E-3, Adam=5E-4)
           'lrf': 0.0005,  # final learning rate (with cos scheduler)
           'momentum': 0.937,  # SGD momentum
           'weight_decay': 0.0005,  # optimizer weight decay
           'fl_gamma': 0.0,  # focal loss gamma (efficientDet default is gamma=1.5)
           'hsv_h': 0.0138,  # image HSV-Hue augmentation (fraction)
           'hsv_s': 0.678,  # image HSV-Saturation augmentation (fraction)
           'hsv_v': 0.36,  # image HSV-Value augmentation (fraction)
           'degrees': 1.98 * 0,  # image rotation (+/- deg)
           'translate': 0.05 * 0,  # image translation (+/- fraction)
           'scale': 0.05 * 0,  # image scale (+/- gain)
           'shear': 0.641 * 0}  # image shear (+/- deg)

    device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    model = Darknet(opt.cfg).to(device)

    if opt.weights:
        if opt.weights.endswith(".pt"):
            model.load_state_dict(torch.load(opt.weights, map_location=device)['model'])
        else:
            _ = load_darknet_weights(model, opt.weights)

    data_config = parse_data_cfg(opt.data)

    valid_path = data_config["valid"]
    train_path = data_config["train"]
    class_names = load_classes(data_config["names"])
    steps = math.ceil((len(open(train_path).readlines()) / batch_size) * 0.1)

    obtain_num_parameters = lambda model: sum([param.nelement() for param in model.parameters()])

    dataset = LoadImagesAndLabels(train_path,
                                  img_size,
                                  batch_size,
                                  augment=True,
                                  hyp=hyp,  # augmentation hyperparameters
                                  rect=False,  # rectangular training
                                  cache_images=False)

    dataloader = torch.utils.data.DataLoader(dataset,
                                             batch_size=batch_size,
                                             num_workers=min([os.cpu_count(), batch_size, 16]),
                                             shuffle=True,  # Shuffle=True unless rectangular training is used
                                             pin_memory=True,
                                             collate_fn=dataset.collate_fn)

    test_dataset = LoadImagesAndLabels(valid_path, img_size, batch_size,
                                       hyp=hyp,
                                       rect=True,
                                       cache_images=False)
    testloader = torch.utils.data.DataLoader(test_dataset,
                                             batch_size=batch_size,
                                             num_workers=min([os.cpu_count(), batch_size, 8]),
                                             shuffle=False,
                                             pin_memory=True,
                                             collate_fn=test_dataset.collate_fn)
    with torch.no_grad():
        origin_model_metric = test.test(opt.cfg,
                                        opt.data,
                                        batch_size=batch_size,
                                        imgsz=img_size,
                                        model=model,
                                        dataloader=testloader,
                                        rank=-1,
                                        plot=False)
    origin_nparameters = obtain_num_parameters(model)
    origin_macs = performance_summary(model)

    CBL_idx, Conv_idx, prune_idx, _, _ = parse_module_defs2(model.module_defs)

    print("-------------------------------------------------------")

    max_mAP = 0
    for i in range(number):
        compact_module_defs, current_parameters, compact_model = rand_prune_and_eval(model, 0, 1)
        with torch.no_grad():
            # 防止随机生成的较差的模型撑爆显存,增大nmsconf阈值
            mAP = test.test(opt.cfg,
                            opt.data,
                            batch_size=batch_size,
                            imgsz=img_size,
                            conf_thres=0.1,
                            model=compact_model,
                            dataloader=testloader,
                            rank=-1,
                            plot=False)[0][2]

        print('candidate: ' + str(i), end=" ")
        print('remain_ratio: ' + str(current_parameters / origin_nparameters))
        print(f'mAP of the pruned model is {mAP:.4f}')
        if mAP > max_mAP:
            max_mAP = mAP
            compact_model_winnner = deepcopy(compact_model)
            cfg_name = 'cfg_backup/' + str(i) + '.cfg'
            if not os.path.isdir('cfg_backup/'):
                os.makedirs('cfg_backup/')
            pruned_cfg_file = write_cfg(cfg_name, [model.hyperparams.copy()] + compact_module_defs)
        del compact_model
        torch.cuda.empty_cache()
    # 获得原始模型的module_defs,并修改该defs中的卷积核数量
    compact_module_defs = deepcopy(compact_model_winnner.module_defs)
    compact_nparameters = obtain_num_parameters(compact_model_winnner)

    compact_macs =  performance_summary(compact_model_winnner)
    compact_flops =  compact_macs*2 / 1024**3
    origin_flops = origin_macs*2 / 1024**3

    random_input = torch.rand((16, 3, 416, 416)).to(device)

    pruned_forward_time, pruned_output = obtain_avg_forward_time(random_input, model)
    compact_forward_time, compact_output = obtain_avg_forward_time(random_input, compact_model_winnner)

    # 在测试集上测试剪枝后的模型, 并统计模型的参数数量
    with torch.no_grad():
        compact_model_metric = test.test(opt.cfg,
                                         opt.data,
                                         batch_size=batch_size,
                                         imgsz=img_size,
                                         model=compact_model_winnner,
                                         dataloader=testloader,
                                         rank=-1,
                                         plot=False)

    # 比较剪枝前后参数数量的变化、指标性能的变化
    metric_table = [
        ["Metric", "Before", "After"],
        ["mAP", f'{origin_model_metric[1].mean():.6f}', f'{compact_model_metric[1].mean():.6f}'],
        ["Parameters", f"{origin_nparameters}", f"{compact_nparameters}"],
        ["GFLOPs",f"{origin_flops}",f"{compact_flops}"],
        ["Inference", f'{pruned_forward_time:.4f}', f'{compact_forward_time:.4f}']
    ]
    print(AsciiTable(metric_table).table)

    # 生成剪枝后的cfg文件并保存模型
    pruned_cfg_name = 'cfg/rand-slim_' + str(remain_ratio) + '_' + str(number) + '/' + 'rand-slim_' + str(
        remain_ratio) + '_' + str(number) + '.cfg'
    # 创建存储目录
    dir_name = 'cfg/rand-slim_' + str(remain_ratio) + '_' + str(number) + '/'
    if not os.path.isdir(dir_name):
        os.makedirs(dir_name)

    # 由于原始的compact_module_defs将anchor从字符串变为了数组,因此这里将anchors重新变为字符串
    file = open(opt.cfg, 'r')
    lines = file.read().split('\n')
    for line in lines:
        if line.split(' = ')[0] == 'anchors':
            anchor = line.split(' = ')[1]
            break
        if line.split('=')[0] == 'anchors':
            anchor = line.split('=')[1]
            break
    file.close()
    for item in compact_module_defs:
        if item['type'] == 'shortcut':
            item['from'] = str(item['from'][0])
        elif item['type'] == 'route':
            item['layers'] = ",".join('%s' % i for i in item['layers'])
        elif item['type'] == 'yolo':
            item['mask'] = ",".join('%s' % i for i in item['mask'])
            item['anchors'] = anchor
    pruned_cfg_file = write_cfg(pruned_cfg_name, [model.hyperparams.copy()] + compact_module_defs)
    print(f'Config file has been saved: {pruned_cfg_file}')
    weights_dir_name = dir_name.replace('cfg', 'weights')
    if not os.path.isdir(weights_dir_name):
        os.makedirs(weights_dir_name)
    compact_model_name = weights_dir_name + 'rand-slim_' + str(remain_ratio) + '_' + str(number) + '.weights'

    save_weights(compact_model_winnner, path=compact_model_name)
    print(f'Compact model has been saved: {compact_model_name}')
    print('%g sub networks completed in %.3f hours.\n' % (number, (time.time() - t0) / 3600))


================================================
FILE: LICENSE
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    <program>  Copyright (C) <year>  <name of author>
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.


================================================
FILE: PTQ.py
================================================
import argparse
import test
from torch.utils.data import DataLoader
from models import *
from utils.datasets import *
from utils.utils import *

wdir = 'weights' + os.sep  # weights dir
PTQ_weights = wdir + 'PTQ.pt'


def PTQ(cfg,
        data,
        weights=None,
        batch_size=64,
        imgsz=416,
        augment=False,
        a_bit=8,
        w_bit=8, ):
    # Initialize/load model and set device
    device = torch_utils.select_device(opt.device, batch_size=batch_size)
    print('PTQ only support for one gpu!')
    print('')  # skip a line
    # Initialize model
    model = Darknet(cfg, is_gray_scale=opt.gray_scale, maxabsscaler=opt.maxabsscaler)
    q_model = Darknet(cfg, quantized=3, a_bit=a_bit, w_bit=w_bit, is_gray_scale=opt.gray_scale,
                      maxabsscaler=opt.maxabsscaler,
                      shortcut_way=opt.shortcut_way)

    # Load weights
    attempt_download(weights)
    if weights.endswith('.pt'):  # pytorch format
        model.load_state_dict(torch.load(weights, map_location=device)['model'])
        q_model.load_state_dict(torch.load(weights, map_location=device)['model'])
    else:  # darknet format
        load_darknet_weights(model, weights)
        load_darknet_weights(q_model, weights, quant=True)

    model.to(device)
    q_model.to(device)

    # Configure run
    data_dict = parse_data_cfg(data)
    cali_path = data_dict['train']
    test_path = data_dict['valid']

    # Dataloader
    cali_dataset = LoadImagesAndLabels(cali_path, imgsz, batch_size, rect=True,
                                    is_gray_scale=True if opt.gray_scale else False, subset_len=opt.subset_len)
    cali_batch_size = min(batch_size, len(cali_dataset))
    cali_dataloader = DataLoader(cali_dataset,
                              batch_size=cali_batch_size,
                              num_workers=min([os.cpu_count(), batch_size if batch_size > 1 else 0, 8]),
                              pin_memory=True,
                              collate_fn=cali_dataset.collate_fn)

    test_dataset = LoadImagesAndLabels(test_path, imgsz, batch_size, rect=True,
                                    is_gray_scale=True if opt.gray_scale else False)
    test_batch_size = min(batch_size, len(test_dataset))
    test_dataloader = DataLoader(test_dataset,
                              batch_size=test_batch_size,
                              num_workers=min([os.cpu_count(), batch_size if batch_size > 1 else 0, 8]),
                              pin_memory=True,
                              collate_fn=test_dataset.collate_fn)
    print('')  # skip a line
    print('<.....................test original model.......................>')
    test.test(cfg,
              data=opt.data,
              batch_size=batch_size,
              imgsz=imgsz,
              model=model,
              dataloader=test_dataloader,
              rank=-1,
              maxabsscaler=opt.maxabsscaler)

    q_model.train()
    print('')  # skip a line
    print('<.....................Quantize.......................>')

    for batch_i, (imgs, _, _, _) in enumerate(tqdm(cali_dataloader)):
        if opt.maxabsscaler:
            imgs = imgs.to(device).float() / 256.0  # uint8 to float32, 0 - 255 to 0.0 - 1.0
            imgs = imgs * 2 - 1
        else:
            imgs = imgs.to(device).float() / 256.0  # uint8 to float32, 0 - 255 to 0.0 - 1.0
        # Disable gradients
        with torch.no_grad():
            _, _ = q_model(imgs, augment=augment)  # inference and training outputs
    print('')  # skip a line
    print('<.....................test quantized model.......................>')
    print('')  # skip a line
    test.test(cfg,
              data=opt.data,
              batch_size=batch_size,
              imgsz=imgsz,
              model=q_model,
              dataloader=test_dataloader,
              quantized=3,
              a_bit=opt.a_bit,
              w_bit=opt.w_bit,
              rank=-1,
              maxabsscaler=opt.maxabsscaler)
    # Save model

    if hasattr(q_model, 'module'):
        model_temp = q_model.module.state_dict()
    else:
        model_temp = q_model.state_dict()
    chkpt = {'epoch': None,
             'best_fitness': None,
             'training_results': None,
             'model': model_temp,
             'optimizer': None}
    # Save last, best and delete
    torch.save(chkpt, PTQ_weights)
    del chkpt


if __name__ == '__main__':
    parser = argparse.ArgumentParser(prog='test.py')
    parser.add_argument('--cfg', type=str, default='cfg/yolov3-spp.cfg', help='*.cfg path')
    parser.add_argument('--data', type=str, default='data/coco2014.data', help='*.data path')
    parser.add_argument('--weights', type=str, default='weights/yolov3-spp-ultralytics.pt', help='weights path')
    parser.add_argument('--batch-size', type=int, default=16, help='size of each image batch')
    parser.add_argument('--img-size', type=int, default=512, help='inference size (pixels)')
    parser.add_argument('--device', default='', help='device id (i.e. 0 or 0,1) or cpu')
    parser.add_argument('--single-cls', action='store_true', help='train as single-class dataset')
    parser.add_argument('--augment', action='store_true', help='augmented inference')
    parser.add_argument('--a-bit', type=int, default=8,
                        help='a-bit')
    parser.add_argument('--w-bit', type=int, default=8,
                        help='w-bit')
    parser.add_argument('--subset_len', type=int, default=-1, help='calibration set len')
    parser.add_argument('--gray_scale', action='store_true', help='gray scale trainning')
    parser.add_argument('--maxabsscaler', '-mas', action='store_true', help='Standarize input to (-1,1)')
    parser.add_argument('--shortcut_way', type=int, default=1, help='--shortcut quantization way')
    opt = parser.parse_args()
    opt.cfg = list(glob.iglob('./**/' + opt.cfg, recursive=True))[0]  # find file
    opt.data = list(glob.iglob('./**/' + opt.data, recursive=True))[0]  # find file

    print(opt)

    PTQ(opt.cfg,
        opt.data,
        opt.weights,
        opt.batch_size,
        opt.img_size,
        opt.augment,
        a_bit=opt.a_bit,
        w_bit=opt.w_bit)


================================================
FILE: README.md
================================================
# YOLOv3-ModelCompression-MultidatasetTraining

This project mainly include three parts.

1.Provides training methods for multiple mainstream object detection datasets(coco2017, coco2014, BDD100k, Visdrone,
Hand)

2.Provides a mainstream model compression algorithm including pruning, quantization, and knowledge distillation.

3.Provides multiple backbone for yolov3 including Darknet-YOLOv3,Tiny-YOLOv3,Mobilenetv3-YOLOv3

Source using Pytorch implementation to [ultralytics/yolov3](https://github.com/ultralytics/yolov3) for yolov3 source
code. Pruning method based on BN layer
by [coldlarry/YOLOv3-complete-pruning](https://github.com/coldlarry/YOLOv3-complete-pruning), thanks to both of you.

**If you can't download weights file and datasets from BaiDu, please send e-mail(spurslipu@pku.edu.cn) to me, I will 
rely as soon as I can.**

# Update

January 4, 2020. Provides download links and training methods to the Visdrone dataset.

January 19, 2020. Dior, Bdd100k and Visdrone training will be provided, as well as the converted weights file.

March 1, 2020. Provides Mobilenetv3 backbone.

April 7, 2020. Implement two models based on Mobilenetv3: Yolov3-Mobilenet, and Yolov3tin-Mobilene-small, provide
pre-training weights, extend the normal pruning methods to the two Mobilenet-based models.

April 27, 2020. Update mobilenetv3 pre-training weights, add a layer pruning method, methods from
the [tanluren/yolov3-channel-and-layer-pruning/yolov3](https://github.com/tanluren/yolov3-channel-and-layer-pruning),
Thanks for sharing.

May 22, 2020. Updated some new optimizations from [ultralytics/yolov3](https://github.com/ultralytics/yolov3), update
cfg file and weights of YOLOv4.

May 22, 2020. The 8-bit quantization method was updated and some bugs were fixed.

July 12, 2020. The problem of mAP returning to 0 after pruning in yolov3-mobilenet was fixed. See issue#41 for more
details.

September 30, 2020. The BN_Fold training method was updated to reduce the precision loss caused by BN fusion, and the
POW (2) quantization method targeted at FPGA was updated. See the quantization section for details.

# Requirements

Our project based on [ultralytics/yolov3](https://github.com/ultralytics/yolov3),
see [ultralytics/yolov3](https://github.com/ultralytics/yolov3) for details. Here is a brief explanation:

- `numpy`
- `torch >= 1.1.0`
- `opencv-python`
- `tqdm`

# Current support

|<center>Function</center>|<center></center>|
| --- |--- |
|<center>Multi-Backbone training</center>|<center>√</center>  |
|<center>Multi-Datasets</center>|<center>√</center>  |
|<center>Pruning</center>|<center>√</center>  |
|<center>Quantization</center>|<center>√</center>  |
|<center>Knowledge Distillation</center>|<center>√</center>  |

# Training

`python3 train.py --data ... --cfg ... `For training model command, the -pt command is required when using coco
pre-training model.

`python3 test.py --data ... --cfg ... ` For testing model command

`python3 detect.py --data ... --cfg ... --source ...` For detecting model command, the default address of source is
data/samples, the output result is saved in the /output, and the detection resource can be pictures and videos.

# Multi-Datasets

This project provides preprocessed datasets for the YOLOv3, configuration files (.cfg), dataset index files (.data),
dataset category files (.names), and anchor box sizes (including 9 boxes for YOLOv3 and 6 boxes for tiny- YOLOv3) that
are reclustered using the K-means algorithm.

mAP

|<center>Dataset</center>|<center>YOLOv3-640</center>|<center>YOLOv4-640</center>|<center>YOLOv3-mobilenet-640</center>|
| --- |--- |--- |--- |
|<center>Dior</center>|<center>0.749</center>|
|<center>bdd100k</center>|<center>0.543</center>|
|<center>visdrone</center>|<center>0.311</center>|<center>0.383</center>|<center>0.348</center>|

Datasets, download and unzip to /data.

- [COCO2017](https://pan.baidu.com/s/1KysFL6AmdbCBq4tHDebqlw)

  Extract code:hjln

- [COCO2014](https://pan.baidu.com/s/1EoXOR77yEVokqPCaxg8QGg)

  Extract code:rhqx

- [COCO weights](https://pan.baidu.com/s/1JZylwRQIgAd389oWUu0djg)

  Extract code:k8ms

Training command

```bash
python3 train.py --data data/coco2017.data --batch-size ... --weights weights/yolov3-608.weights -pt --cfg cfg/yolov3/yolov3.cfg --img-size ... --epochs ...
```

- [Dior](https://pan.baidu.com/s/1z0IQPBN16I-EctjwN9Idyg)

  Extract code:vnuq

- [Dior weights](https://pan.baidu.com/s/12lYOgBAo1R5VkOZqDqCFJQ)

  Extract code:l8wz

Training command

```bash
python3 train.py --data data/dior.data --batch-size ... --weights weights/yolov3-608.weights -pt --cfg cfg/yolov3/yolov3-onDIOR.cfg --img-size ... --epochs ...
```

- [bdd100k](https://pan.baidu.com/s/157Md2qeFgmcOv5UmnIGI_g)

  Extract code:8duw

- [bdd100k weights](https://pan.baidu.com/s/1wWiHlLxIaK_WHy_mG2wmAA)

  Extract code:xeqo

Training command

```bash
python3 train.py --data data/bdd100k.data --batch-size ... --weights weights/yolov3-608.weights -pt --cfg cfg/yolov3/yolov3-bdd100k.cfg --img-size ... --epochs ...
```

- [visdrone](https://pan.baidu.com/s/1CPGmS3tLI7my4_m7qDhB4Q)

  Extract code:dy4c

- [YOLOv3-visdrone weights](https://pan.baidu.com/s/1N4qDP3b0tt8TIWuTFefDEw)

  Extract code:87lf

- [YOLOv4-visdrone weights](https://pan.baidu.com/s/1zOFyt_AFiNk0fAFa8yE9RQ)

  Extract code:xblu

- [YOLOv3-mobilenet-visdrone weights](https://pan.baidu.com/s/1BHC8b6xHmTuN8h74QJFt1g)

Extract code:fb6y

Training command

```bash
python train.py --data data/visdrone.data --batch-size ... --weights weights/yolov3-608.weights -pt --cfg cfg/yolov3/yolov3-visdrone.cfg  --img-size ... --epochs ...
```

- [oxfordhand](https://pan.baidu.com/s/1JL4gFGh-W_gYEEsiIQssZw)

  Extract code:3du4

Training command

```bash
python train.py --data data/oxfordhand.data --batch-size ... --weights weights/yolov3-608.weights -pt --cfg cfg/yolov3/yolov3-hand.cfg  --img-size ... --epochs ...
```

## 1.Dior

The DIRO dataset is one of the largest, most diverse, and publicly available object detection datasets in the Earth
observation community. Among them, the number of instances of ships and vehicles is high, which achieves a good balance
between small instances and large ones. The images were collected from Google Earth.

[Introduction](https://cloud.tencent.com/developer/article/1509762)

### Test results

![Test results](https://github.com/SpursLipu/YOLOv3-ModelCompression-MultidatasetTraining/blob/master/image_in_readme/2.jpg)
![Test results](https://github.com/SpursLipu/YOLOv3-ModelCompression-MultidatasetTraining/blob/master/image_in_readme/3.jpg)

## 2.bdd100k

Bdd100 is a large, diverse data set of driving videos containing 100,000 videos. Each video was about 40 seconds long,
and the researchers marked bounding boxes for all 100,000 key frames of objects that often appeared on the road. The
data set covers different weather conditions, including sunny, cloudy and rainy days, and different times of day and
night.

[Website](http://bair.berkeley.edu/blog/2018/05/30/bdd/)

[Download](http://bdd-data.berkeley.edu)

[Paper](https://arxiv.org/abs/1805.04687)

### Test results

![Test results](https://github.com/SpursLipu/YOLOv3-ModelCompression-MultidatasetTraining/blob/master/image_in_readme/1.jpg)

## 3.Visdrone

The VisDrone2019 dataset was collected by AISKYEYE team at the Machine Learning and Data Mining Laboratory at Tianjin
University, China. Benchmark data set contains 288 video clips, and consists of 261908 frames and 10209 frames a static
image, by all sorts of installed on the unmanned aerial vehicle (uav) camera capture, covers a wide range of aspects,
including location (thousands of kilometers apart from China in 14 different cities), environment (city and country),
object (pedestrians, vehicles, bicycles, etc.) and density (sparse and crowded scenario). This data set was collected
using a variety of uav platforms (i.e., uAvs with different models) in a variety of situations and under various weather
and light conditions. These frames are manually marked with more than 2.6 million border frames, which are often targets
of interest, such as pedestrians, cars, bicycles and tricycles. Some important attributes are also provided, including
scene visibility, object categories, and occlusion, to improve data utilization.

[Website](http://www.aiskyeye.com/)

### Test results of YOLOv3

![Test results](https://github.com/SpursLipu/YOLOv3-ModelCompression-MultidatasetTraining/blob/master/image_in_readme/4.jpg)

### Test results of YOLOv4

![Test results](https://github.com/SpursLipu/YOLOv3-ModelCompression-MultidatasetTraining/blob/master/image_in_readme/5.jpg)
![Test results](https://github.com/SpursLipu/YOLOv3-ModelCompression-MultidatasetTraining/blob/master/image_in_readme/6.png)

# Multi-Backbone

Based on mobilenetv3, two network structures are designed.

|Structure |<center>backbone</center>|<center>Postprocessing</center> |<center>Parameters</center> |<center>GFLOPS</center> |<center>mAP0.5</center> |<center>mAP0.5:0.95</center> |<center>speed(inference/NMS/total)</center> |<center>FPS</center> |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|YOLOv3                      |38.74M  |20.39M  |59.13M  |117.3   |0.580  |0.340  |12.3/1.7/14.0 ms|71.4fps  |
|YOLOv3tiny                  |6.00M   |2.45M   |8.45M   |9.9     |0.347  |0.168  |3.5/1.8/5.3 ms  |188.7fps |
|YOLOv3-mobilenetv3          |2.84M   |20.25M  |23.09M  |32.2    |0.547  |0.346  |7.9/1.8/9.7 ms  |103.1fps |
|YOLOv3tiny-mobilenetv3-small|0.92M   |2.00M   |2.92M   |2.9     |0.379  |0.214  |5.2/1.9/7.1 ms  |140.8fps |
|YOLOv4                      |-       |-       |61.35M  |107.1   |0.650  |0.438  |13.5/1.8/15.3 ms|65.4fps  |
|YOLOv4-tiny                 |-       |-       |5.78M   |12.3    |0.435  |0.225  |4.1/1.7/5.8 ms  |172.4fps |

1. YOLOv3,YOLOv3tiny and YOLOv4 were trained and tested on coco2014, and Yolov3-Mobilenetv3 and YOLOv3tiny
   Mobilenetv3-Small were trained and tested on coco2017.

2. The inference speed test on GTX2080ti*4, and image size is 608.

3. The training set should match the testing set, because mismatch will cause the mistakes of mAP.
   Read [issue](https://github.com/ultralytics/yolov3/issues/970) for detial.

## Train command

1.YOLOv3

```bash
python3 train.py --data data/... --batch-size ... -pt --weights weights/yolov3-608.weights --cfg cfg/yolov3/yolov3.cfg --img_size ...
```

Weights Download

- [COCO pretraining weights](https://pan.baidu.com/s/1JZylwRQIgAd389oWUu0djg)

  Extract code:k8ms

2.YOLOv3tiny

```bash
python3 train.py --data data/... --batch-size ... -pt --weights weights/yolov3tiny.weights --cfg cfg/yolov3tiny/yolov3-tiny.cfg --img_size ...
```

- [COCO pretraining weights](https://pan.baidu.com/s/1iWGxdjR3TWxEe37__msyRA)

  Extract code:udfe

3.YOLOv3tiny-mobilenet-small

```bash
python3 train.py --data data/... --batch-size ... -pt --weights weights/yolov3tiny-mobilenet-small.weights --cfg cfg/yolov3tiny-mobilenet-small/yolov3tiny-mobilenet-small-coco.cfg --img_size ...
```

- [COCO pretraining weights](https://pan.baidu.com/s/1mSFjWLU91H2OhNemsAeiiQ)

  Extract code:pxz4

4.YOLOv3-mobilenet

```bash
python3 train.py --data data/... --batch-size ... -pt --weights weights/yolov3-mobilenet.weights --cfg cfg/yolov3-mobilenet/yolov3-mobilenet-coco.cfg --img_size ...
```

- [COCO pretraining weights](https://pan.baidu.com/s/1EI2Xh1i18CRLoZo_P3NVHw)

  Extract code:3vm8

5.YOLOv4

```bash
python3 train.py --data data/... --batch-size ... -pt --weights weights/yolov4.weights --cfg cfg/yolov4/yolov4.cfg --img_size ...
```

- [COCO pretraining weights](https://pan.baidu.com/s/1jAGNNC19oQhAIgBfUrkzmQ)

  Extract code:njdg

# Model Compression

## 1. Pruning

### Features

|<center>method</center> |<center>advantage</center>|<center>disadvantage</center> |
| --- | --- | --- |
|Normal pruning        |Not prune for shortcut layer. It has a considerable and stable compression rate but requires no fine tuning.|The compression rate is limited.  |
|Shortcut pruning      |Very high compression rate.  |Fine-tuning is necessary.  |
|Silmming              |Shortcut fusion method is used to improve the precision of shear planting.|Best way for shortcut pruning|
|Regular pruning       |Designed for hardware deployment, the number of filters after pruning is a multiple of 2, no fine-tuning, support tiny-yolov3 and Mobilenet.|Part of the compression ratio is sacrificed for regularization. |
|layer pruning         |ResBlock is used as the basic unit for purning, which is conducive to hardware deployment. |It can only cut backbone. |
|layer-channel pruning |First, use channel pruning and then use layer pruning, and pruning rate was very high. |Accuracy may be affected. |

### Step

1.Training

```bash
python3 train.py --data ... -pt --batch-size ... --weights ... --cfg ...
```

2.Sparse training

`--s`Specifies the sparsity factor,`--prune`Specify the sparsity type.

`--prune 0` is the sparsity of normal pruning and regular pruning.

`--prune 1` is the sparsity of shortcut pruning.

`--prune 2` is the sparsity of layer pruning.

command:

```bash
python3 train.py --data ... -pt --batch-size 32  --weights ... --cfg ... --s 0.001 --prune 0 
```

3.Pruning

- normal pruning

```bash
python3 normal_prune.py --cfg ... --data ... --weights ... --percent ...
```

- regular pruning

```bash
python3 regular_prune.py --cfg ... --data ... --weights ... --percent ...
```

- shortcut pruning

```bash
python3 shortcut_prune.py --cfg ... --data ... --weights ... --percent ...
```

- silmming

```bash
python3 slim_prune.py --cfg ... --data ... --weights ... --percent ...
```

- layer pruning

```bash
python3 layer_prune.py --cfg ... --data ... --weights ... --shortcut ...
```

- layer-channel pruning

```bash
python3 layer_channel_prune.py --cfg ... --data ... --weights ... --shortcut ... --percent ...
```

It is important to note that the cfg and weights variables in OPT need to be pointed to the cfg and weights files
generated by step 2.

In addition, you can get more compression by increasing the percent value in the code.
(If the sparsity is not enough and the percent value is too high, the program will report an error.)

### Pruning experiment

1.normal pruning oxfordhand,img_size = 608,test on GTX2080Ti*4

|<center>model</center> |<center>parameter before pruning</center> |<center>mAP before pruning</center>|<center>inference time before pruning</center>|<center>percent</center> |<center>parameter after pruning</center> |<center>mAP after pruning</center> |<center>inference time after pruning</center>
| --- | --- | --- | --- | --- | --- | --- | --- |
|yolov3(without fine tuning)     |58.67M   |0.806   |0.1139s   |0.8    |10.32M |0.802 |0.0844s |
|yolov3-mobilenet(fine tuning)   |22.75M   |0.812   |0.0345s   |0.97   |2.72M  |0.795 |0.0211s |
|yolov3tiny(fine tuning)         |8.27M    |0.708   |0.0144s   |0.5    |1.13M  |0.641 |0.0116s |

2.regular pruning oxfordhand,img_size = 608,test ong GTX2080Ti*4

|<center>model</center> |<center>parameter before pruning</center> |<center>mAP before pruning</center>|<center>inference time before pruning</center>|<center>percent</center> |<center>parameter after pruning</center> |<center>mAP after pruning</center> |<center>inference time after pruning</center>
| --- | --- | --- | --- | --- | --- | --- | --- |
|yolov3(without fine tuning)           |58.67M   |0.806   |0.1139s   |0.8    |12.15M |0.805 |0.0874s |
|yolov3-mobilenet(fine tuning)   |22.75M   |0.812   |0.0345s   |0.97   |2.75M  |0.803 |0.0208s |
|yolov3tiny(fine tuning)         |8.27M    |0.708   |0.0144s   |0.5    |1.82M  |0.703 |0.0122s |

3.shortcut pruning oxfordhand,img_size = 608,test ong GTX2080Ti*4

|<center>model</center> |<center>parameter before pruning</center> |<center>mAP before pruning</center>|<center>inference time before pruning</center>|<center>percent</center> |<center>parameter after pruning</center> |<center>mAP after pruning</center> |<center>inference time after pruning</center>
| --- | --- | --- | --- | --- | --- | --- | --- |
|yolov3           |58.67M   |0.806   |   |0.8    |6.35M  |0.816 | |
|yolov4           |60.94M   |0.896   |   |0.6    |13.97M |0.855 | |

## 2.quantization

`--quantized 2` Dorefa quantization method

```bash
python train.py --data ... --batch-size ... --weights ... --cfg ... --img-size ... --epochs ... --quantized 2
```

`--quantized 1` Google quantization method

```bash
python train.py --data ... --batch-size ... --weights ... --cfg ... --img-size ... --epochs ... --quantized 1
```

`--FPGA` Pow(2) quantization for FPGA.

### experiment

oxfordhand, yolov3, 640image-size

|<center>method</center> |<center>mAP</center> |
| --- | --- |
|Baseline                     |0.847    |
|Google8bit                   |0.851    |
|Google8bit + BN Flod         |0.851    |
|Google8bit + BN Flod + FPGA  |0.852    |
|Google4bit + BN Flod + FPGA  |0.842    |

## 3.Knowledge Distillation

### Knowledge Distillation

The distillation method is based on the basic distillation method proposed by Hinton in 2015, and has been partially
improved in combination with the detection network.

Distilling the Knowledge in a Neural Network
[paper](https://arxiv.org/abs/1503.02531)

command : `--t_cfg --t_weights --KDstr`

`--t_cfg` cfg file of teacher model

`--t_weights` weights file of teacher model

`--KDstr` KD strategy

    `--KDstr 1` KLloss can be obtained directly from the output of teacher network and the output of student network and added to the overall loss.
    `--KDstr 2` To distinguish between box loss and class loss, the student does not learn directly from the teacher. L2 distance is calculated respectively for student, teacher and GT. When student is greater than teacher, an additional loss is added for student and GT.
    `--KDstr 3` To distinguish between Boxloss and ClassLoss, the student learns directly from the teacher.
    `--KDstr 4` KDloss is divided into three categories, box loss, class loss and feature loss.
    `--KDstr 5` On the basis of KDstr 4, the fine-grain-mask is added into the feature

example:

```bash
python train.py --data ... --batch-size ... --weights ... --cfg ... --img-size ... --epochs ... --t_cfg ... --t_weights ...
```

Usually, the pre-compression model is used as the teacher model, and the post-compression model is used as the student
model for distillation training to improve the mAP of student network.

### experiment

oxfordhand,yolov3tiny as teacher model,normal pruning yolov3tiny as student model

|<center>teacher model</center> |<center>mAP of teacher model</center> |<center>student model</center>|<center>directly fine tuning</center>|<center>KDstr 1</center> |<center>KDstr 2</center> |<center>KDstr 3</center>  |<center>KDstr 4(L1)</center> |<center>KDstr 5(L1)</center> |
| --- | --- | --- | --- | --- | --- | --- |--- |--- |
|yolov3tiny608   |0.708    |normal pruning yolov3tiny608    |0.658     |0.666    |0.661  |0.672   |0.673   |0.674   |

================================================
FILE: cfg/yolov2/yolov2-hand.cfg
================================================
[net]
# Testing
batch = 1
subdivisions = 1
# Training
# batch=64
# subdivisions=8
width = 608
height = 608
channels = 3
momentum = 0.9
decay = 0.0005
angle = 0
saturation = 1.5
exposure = 1.5
hue = .1

learning_rate = 0.001
burn_in = 1000
max_batches = 500200
policy = steps
steps = 400000,450000
scales = .1,.1

[convolutional]
batch_normalize = 1
filters = 32
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 64
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 128
size = 3
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 64
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 128
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 128
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 1024
size = 3
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 1024
size = 3
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 1024
size = 3
stride = 1
pad = 1
activation = leaky


#######

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 1024
activation = leaky

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 1024
activation = leaky


[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 1024
activation = leaky

[convolutional]
size = 1
stride = 1
pad = 1
filters = 30
activation = linear


[yolo]
mask = 0,1,2,3,4
anchors = 9,13, 15,21, 24,29, 38,43, 70,74
classes = 1
num = 5
jitter = .3
ignore_thresh = .7
truth_thresh = 1
random = 1

================================================
FILE: cfg/yolov2/yolov2-tiny-hand.cfg
================================================
[net]
batch = 64
subdivisions = 8
width = 416
height = 416
channels = 3
momentum = 0.9
decay = 0.0005
angle = 0
saturation = 1.5
exposure = 1.5
hue = .1

learning_rate = 0.001
max_batches = 40200
policy = steps
steps = -1,100,20000,30000
scales = .1,10,.1,.1

[convolutional]
batch_normalize = 1
filters = 16
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 32
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 64
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 128
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 1

[convolutional]
batch_normalize = 1
filters = 1024
size = 3
stride = 1
pad = 1
activation = leaky

###########

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 1024
activation = leaky

[convolutional]
size = 1
stride = 1
pad = 1
filters = 30
activation = linear

[yolo]
mask = 0,1,2,3,4
anchors = 9,13, 15,21, 24,29, 38,43, 70,74
classes = 1
num = 5
jitter = .3
ignore_thresh = .7
truth_thresh = 1
random = 1


================================================
FILE: cfg/yolov2/yolov2-tiny.cfg
================================================
[net]
batch = 64
subdivisions = 8
width = 416
height = 416
channels = 3
momentum = 0.9
decay = 0.0005
angle = 0
saturation = 1.5
exposure = 1.5
hue = .1

learning_rate = 0.001
max_batches = 40200
policy = steps
steps = -1,100,20000,30000
scales = .1,10,.1,.1

[convolutional]
batch_normalize = 1
filters = 16
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 32
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 64
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 128
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 1

[convolutional]
batch_normalize = 1
filters = 1024
size = 3
stride = 1
pad = 1
activation = leaky

###########

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 1024
activation = leaky

[convolutional]
size = 1
stride = 1
pad = 1
filters = 425
activation = linear

[yolo]
mask = 0,1,2,3,4
anchors = 7,12, 19,30, 45,61, 90,141, 240,279
classes = 80
num = 5
jitter = .3
ignore_thresh = .7
truth_thresh = 1
random = 1


================================================
FILE: cfg/yolov2/yolov2.cfg
================================================
[net]
# Testing
batch = 1
subdivisions = 1
# Training
# batch=64
# subdivisions=8
width = 608
height = 608
channels = 3
momentum = 0.9
decay = 0.0005
angle = 0
saturation = 1.5
exposure = 1.5
hue = .1

learning_rate = 0.001
burn_in = 1000
max_batches = 500200
policy = steps
steps = 400000,450000
scales = .1,.1

[convolutional]
batch_normalize = 1
filters = 32
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 64
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 128
size = 3
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 64
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 128
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 128
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[maxpool]
size = 2
stride = 2

[convolutional]
batch_normalize = 1
filters = 1024
size = 3
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 1024
size = 3
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 1024
size = 3
stride = 1
pad = 1
activation = leaky


#######

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 1024
activation = leaky

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 1024
activation = leaky


[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 1024
activation = leaky

[convolutional]
size = 1
stride = 1
pad = 1
filters = 425
activation = linear


[yolo]
mask = 0,1,2,3,4
anchors = 7,12, 19,30, 45,61, 90,141, 240,279
classes = 80
num = 5
jitter = .3
ignore_thresh = .7
truth_thresh = 1
random = 1

================================================
FILE: cfg/yolov3/yolov3-UAV.cfg
================================================

[net]
# Testing
#batch=1
#subdivisions=1
# Training
batch=16
subdivisions=1
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=1000
max_batches = 500200
policy=steps
steps=400000,450000
scales=.1,.1

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

# Downsample

[convolutional]
batch_normalize=1
filters=64
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=32
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=128
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=256
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=512
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

######################

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=18
activation=linear


[yolo]
mask = 6,7,8
anchors = 5,6, 8,12, 9,8, 10,10, 11,12, 13,16, 15,13, 18,18, 22,25
classes=1
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1


[route]
layers = -4

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 61



[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=18
activation=linear


[yolo]
mask = 3,4,5
anchors = 5,6, 8,12, 9,8, 10,10, 11,12, 13,16, 15,13, 18,18, 22,25
classes=1
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1



[route]
layers = -4

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 36



[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=18
activation=linear


[yolo]
mask = 0,1,2
anchors = 5,6, 8,12, 9,8, 10,10, 11,12, 13,16, 15,13, 18,18, 22,25
classes=1
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1



================================================
FILE: cfg/yolov3/yolov3-asff.cfg
================================================
# Generated by Glenn Jocher (glenn.jocher@ultralytics.com) for https://github.com/ultralytics/yolov3
# def kmean_anchors(path='../coco/train2017.txt', n=12, img_size=(320, 640)):  # from utils.utils import *; kmean_anchors()
# Evolving anchors: 100%|██████████| 1000/1000 [41:15<00:00,  2.48s/it]
# 0.20 iou_thr: 0.992 best possible recall, 4.25 anchors > thr
# kmeans anchors (n=12, img_size=(320, 640), IoU=0.005/0.184/0.634-min/mean/best): 6,9,  15,16,  17,35,  37,26,  36,67,  63,42,  57,100,  121,81,  112,169,  241,158,  195,310,  426,359

[net]
# Testing
# batch=1
# subdivisions=1
# Training
batch=64
subdivisions=16
width=608
height=608
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=1000
max_batches = 500200
policy=steps
steps=400000,450000
scales=.1,.1

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

# Downsample

[convolutional]
batch_normalize=1
filters=64
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=32
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=128
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=256
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=512
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

######################

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

# SPP --------------------------------------------------------------------------
[maxpool]
stride=1
size=5

[route]
layers=-2

[maxpool]
stride=1
size=9

[route]
layers=-4

[maxpool]
stride=1
size=13

[route]
layers=-1,-3,-5,-6
# SPP --------------------------------------------------------------------------

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=258
activation=linear

# YOLO -------------------------------------------------------------------------

[route]
layers = -3

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 61

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=258
activation=linear

# YOLO -------------------------------------------------------------------------

[route]
layers = -3

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 36

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=258
activation=linear

[yolo]
from=88,99,110
mask = 6,7,8
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326
classes=80
num=9

[yolo]
from=88,99,110
mask = 3,4,5
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326
classes=80
num=9

[yolo]
from=88,99,110
mask = 0,1,2
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326
classes=80
num=9

================================================
FILE: cfg/yolov3/yolov3-bdd100k.cfg
================================================
[net]
# Testing
#batch=1
#subdivisions=1
# Training
batch=16
subdivisions=1
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=1000
max_batches = 500200
policy=steps
steps=400000,450000
scales=.1,.1

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

# Downsample

[convolutional]
batch_normalize=1
filters=64
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=32
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=128
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=256
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=512
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

######################

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=45
activation=linear


[yolo]
mask = 6,7,8
anchors = 3,7, 5,18, 6,9, 10,32, 11,14, 17,21, 24,36, 45,59, 93,132
classes=10
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1


[route]
layers = -4

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 61



[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=45
activation=linear


[yolo]
mask = 3,4,5
anchors = 3,7, 5,18, 6,9, 10,32, 11,14, 17,21, 24,36, 45,59, 93,132
classes=10
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1



[route]
layers = -4

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 36



[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=45
activation=linear


[yolo]
mask = 0,1,2
anchors = 3,7, 5,18, 6,9, 10,32, 11,14, 17,21, 24,36, 45,59, 93,132
classes=10
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1


================================================
FILE: cfg/yolov3/yolov3-hand.cfg
================================================

[net]
# Testing
#batch=1
#subdivisions=1
# Training
batch=16
subdivisions=1
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=1000
max_batches = 500200
policy=steps
steps=400000,450000
scales=.1,.1

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

# Downsample

[convolutional]
batch_normalize=1
filters=64
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=32
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=128
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=256
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=512
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

######################

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=18
activation=linear


[yolo]
mask = 6,7,8
anchors = 8,13, 14,20, 22,25, 26,36, 35,49, 40,31, 51,69, 63,47, 94,103
classes=1
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1


[route]
layers = -4

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 61



[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=18
activation=linear


[yolo]
mask = 3,4,5
anchors = 8,13, 14,20, 22,25, 26,36, 35,49, 40,31, 51,69, 63,47, 94,103
classes=1
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1



[route]
layers = -4

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 36



[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=18
activation=linear


[yolo]
mask = 0,1,2
anchors = 8,13, 14,20, 22,25, 26,36, 35,49, 40,31, 51,69, 63,47, 94,103
classes=1
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1



================================================
FILE: cfg/yolov3/yolov3-onDIOR.cfg
================================================
[net]
# Testing
#batch=1
#subdivisions=1
# Training
batch=16
subdivisions=1
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=1000
max_batches = 500200
policy=steps
steps=400000,450000
scales=.1,.1

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

# Downsample

[convolutional]
batch_normalize=1
filters=64
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=32
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=128
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=256
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=512
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

######################

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=75
activation=linear


[yolo]
mask = 6,7,8
anchors = 5,5, 6,13, 10,26, 13,6, 15,15, 27,10, 28,33, 61,74, 167,169
classes=20
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1


[route]
layers = -4

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 61



[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=75
activation=linear


[yolo]
mask = 3,4,5
anchors = 5,5, 6,13, 10,26, 13,6, 15,15, 27,10, 28,33, 61,74, 167,169
classes=20
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1



[route]
layers = -4

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 36



[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=75
activation=linear


[yolo]
mask = 0,1,2
anchors = 5,5, 6,13, 10,26, 13,6, 15,15, 27,10, 28,33, 61,74, 167,169
classes=20
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1


================================================
FILE: cfg/yolov3/yolov3-screw.cfg
================================================
[net]
# Testing
#  batch=1
#  subdivisions=1
# Training
batch=64
subdivisions=16
width=256
height=256
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

# learning_rate=0.0001
# burn_in=1000
# max_batches = 50200
# policy=steps
# steps=40000,45000
# scales=.1,.1
learning_rate=0.0001
burn_in=1000
max_batches = 40000
policy=steps
steps=20000,30000
scales=.1,.1



[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

# Downsample

[convolutional]
batch_normalize=1
filters=64
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=32
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=128
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=256
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=512
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

######################

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=21
activation=linear

[yolo]
mask = 6,7,8
anchors = 20,29, 26,34, 29,40, 33,44, 35,47, 37,50, 39,52, 43,57, 74,87
classes=2
num=9
jitter=.3
ignore_thresh = .5
truth_thresh = 1
random=1

[route]
layers = -4

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 61



[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=21
activation=linear

[yolo]
mask = 3,4,5
anchors = 20,29, 26,34, 29,40, 33,44, 35,47, 37,50, 39,52, 43,57, 74,87
classes=2
num=9
jitter=.3
ignore_thresh = .5
truth_thresh = 1
random=1

[route]
layers = -4

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 36



[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=21
activation=linear

[yolo]
mask = 0,1,2
anchors = 20,29, 26,34, 29,40, 33,44, 35,47, 37,50, 39,52, 43,57, 74,87
classes=2
num=9
jitter=.3
ignore_thresh = .5
truth_thresh = 1
random=1



================================================
FILE: cfg/yolov3/yolov3-ship.cfg
================================================
[net]
# Testing
#batch=1
#subdivisions=1
# Training
batch = 16
subdivisions = 1
width = 416
height = 416
channels = 3
momentum = 0.9
decay = 0.0005
angle = 0
saturation = 1.5
exposure = 1.5
hue = .1

learning_rate = 0.001
burn_in = 1000
max_batches = 500200
policy = steps
steps = 400000,450000
scales = .1,.1

[convolutional]
batch_normalize = 1
filters = 32
size = 3
stride = 1
pad = 1
activation = leaky

# Downsample

[convolutional]
batch_normalize = 1
filters = 64
size = 3
stride = 2
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 32
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 64
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

# Downsample

[convolutional]
batch_normalize = 1
filters = 128
size = 3
stride = 2
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 64
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 128
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

[convolutional]
batch_normalize = 1
filters = 64
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 128
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

# Downsample

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 2
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 128
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

[convolutional]
batch_normalize = 1
filters = 128
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

[convolutional]
batch_normalize = 1
filters = 128
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

[convolutional]
batch_normalize = 1
filters = 128
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear


[convolutional]
batch_normalize = 1
filters = 128
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

[convolutional]
batch_normalize = 1
filters = 128
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

[convolutional]
batch_normalize = 1
filters = 128
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

[convolutional]
batch_normalize = 1
filters = 128
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

# Downsample

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 2
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear


[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear


[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear


[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear


[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear


[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

# Downsample

[convolutional]
batch_normalize = 1
filters = 1024
size = 3
stride = 2
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 1024
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

[convolutional]
batch_normalize = 1
filters = 512
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 1024
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

[convolutional]
batch_normalize = 1
filters = 512
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 1024
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

[convolutional]
batch_normalize = 1
filters = 512
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
filters = 1024
size = 3
stride = 1
pad = 1
activation = leaky

[shortcut]
from = -3
activation = linear

######################

[convolutional]
batch_normalize = 1
filters = 512
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 1024
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 1024
activation = leaky

[convolutional]
batch_normalize = 1
filters = 512
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 1024
activation = leaky

[convolutional]
size = 1
stride = 1
pad = 1
filters = 30
activation = linear


[yolo]
mask = 6,7,8
anchors = 112,107, 148,331, 184,196, 234,284, 297,135, 297,350, 352,261, 358,193, 377,352
classes = 5
num = 9
jitter = .3
ignore_thresh = .7
truth_thresh = 1
random = 1


[route]
layers = -4

[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[upsample]
stride = 2

[route]
layers = -1, 61



[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 512
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 512
activation = leaky

[convolutional]
batch_normalize = 1
filters = 256
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 512
activation = leaky

[convolutional]
size = 1
stride = 1
pad = 1
filters = 30
activation = linear


[yolo]
mask = 3,4,5
anchors = 112,107, 148,331, 184,196, 234,284, 297,135, 297,350, 352,261, 358,193, 377,352
classes = 5
num = 9
jitter = .3
ignore_thresh = .7
truth_thresh = 1
random = 1



[route]
layers = -4

[convolutional]
batch_normalize = 1
filters = 128
size = 1
stride = 1
pad = 1
activation = leaky

[upsample]
stride = 2

[route]
layers = -1, 36



[convolutional]
batch_normalize = 1
filters = 128
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 256
activation = leaky

[convolutional]
batch_normalize = 1
filters = 128
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 256
activation = leaky

[convolutional]
batch_normalize = 1
filters = 128
size = 1
stride = 1
pad = 1
activation = leaky

[convolutional]
batch_normalize = 1
size = 3
stride = 1
pad = 1
filters = 256
activation = leaky

[convolutional]
size = 1
stride = 1
pad = 1
filters = 30
activation = linear


[yolo]
mask = 0,1,2
anchors = 112,107, 148,331, 184,196, 234,284, 297,135, 297,350, 352,261, 358,193, 377,352
classes = 5
num = 9
jitter = .3
ignore_thresh = .7
truth_thresh = 1
random = 1


================================================
FILE: cfg/yolov3/yolov3-spp-matrix.cfg
================================================
[net]
# Testing
# batch=1
# subdivisions=1
# Training
batch=64
subdivisions=16
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=1000
max_batches = 500500
policy=steps
steps=400000,450000
scales=.1,.1

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

# Downsample

[convolutional]
batch_normalize=1
filters=64
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=32
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=128
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=256
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=512
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

######################

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

### SPP ###
[maxpool]
stride=1
size=5

[route]
layers=-2

[maxpool]
stride=1
size=9

[route]
layers=-4

[maxpool]
stride=1
size=13

[route]
layers=-1,-3,-5,-6

### End SPP ###

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky


[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=255
activation=linear

# 89
[yolo]
mask = 6,7,8
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326, 10,7,  16,15,  33,12, 5,13,  8,30,  17,23,  30,31,  62,23,  59,60,  15,61,  31,45,  30,119,  116,45,  156,99,  373,163,  58,90,  78,198,  187,326
classes=80
num=27
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1


[route]
layers = -4

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 61



[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=255
activation=linear

# 101
[yolo]
mask = 3,4,5
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326, 10,7,  16,15,  33,12, 5,13,  8,30,  17,23,  30,31,  62,23,  59,60,  15,61,  31,45,  30,119,  116,45,  156,99,  373,163,  58,90,  78,198,  187,326
classes=80
num=27
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1



[route]
layers = -4

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 36



[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=255
activation=linear

# 113
[yolo]
mask = 0,1,2
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326, 10,7,  16,15,  33,12, 5,13,  8,30,  17,23,  30,31,  62,23,  59,60,  15,61,  31,45,  30,119,  116,45,  156,99,  373,163,  58,90,  78,198,  187,326
classes=80
num=27
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1

##################

[route]
layers = 110

# 115
[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

# 116
[convolutional]
batch_normalize=1
filters=128
size=1
stride_x=1
stride_y=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=255
activation=linear

[yolo]
mask = 9,10,11
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326, 10,7,  16,15,  33,12, 5,13,  8,30,  17,23,  30,31,  62,23,  59,60,  15,61,  31,45,  30,119,  116,45,  156,99,  373,163,  58,90,  78,198,  187,326
classes=80
num=27
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1



[route]
layers = 110

# 121
[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

# 122
[convolutional]
batch_normalize=1
filters=128
size=1
stride_x=2
stride_y=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=255
activation=linear

[yolo]
mask = 12,13,14
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326, 10,7,  16,15,  33,12, 5,13,  8,30,  17,23,  30,31,  62,23,  59,60,  15,61,  31,45,  30,119,  116,45,  156,99,  373,163,  58,90,  78,198,  187,326
classes=80
num=27
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1

##################

[route]
layers = 98

[convolutional]
share_index=115
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
share_index=116
batch_normalize=1
filters=128
size=1
stride_x=1
stride_y=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=255
activation=linear

[yolo]
mask = 15,16,17
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326, 10,7,  16,15,  33,12, 5,13,  8,30,  17,23,  30,31,  62,23,  59,60,  15,61,  31,45,  30,119,  116,45,  156,99,  373,163,  58,90,  78,198,  187,326
classes=80
num=27
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1



[route]
layers = 98

[convolutional]
share_index=121
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
share_index=122
batch_normalize=1
filters=128
size=1
stride_x=2
stride_y=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=255
activation=linear

[yolo]
mask = 18,19,20
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326, 10,7,  16,15,  33,12, 5,13,  8,30,  17,23,  30,31,  62,23,  59,60,  15,61,  31,45,  30,119,  116,45,  156,99,  373,163,  58,90,  78,198,  187,326
classes=80
num=27
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1

##################

[route]
layers = 86

[convolutional]
share_index=115
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
share_index=116
batch_normalize=1
filters=128
size=1
stride_x=1
stride_y=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=255
activation=linear

[yolo]
mask = 21,22,23
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326, 10,7,  16,15,  33,12, 5,13,  8,30,  17,23,  30,31,  62,23,  59,60,  15,61,  31,45,  30,119,  116,45,  156,99,  373,163,  58,90,  78,198,  187,326
classes=80
num=27
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1



[route]
layers = 86

[convolutional]
share_index=121
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
share_index=122
batch_normalize=1
filters=128
size=1
stride_x=2
stride_y=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=255
activation=linear

[yolo]
mask = 24,25,26
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326, 10,7,  16,15,  33,12, 5,13,  8,30,  17,23,  30,31,  62,23,  59,60,  15,61,  31,45,  30,119,  116,45,  156,99,  373,163,  58,90,  78,198,  187,326
classes=80
num=27
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1

================================================
FILE: cfg/yolov3/yolov3-spp-pan-scale.cfg
================================================
[net]
# Testing
#batch=1
#subdivisions=1
# Training
batch=64
subdivisions=32
width=544
height=544
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1


learning_rate=0.001
burn_in=1000
max_batches = 10000

policy=steps
steps=8000,9000
scales=.1,.1

#policy=sgdr
#sgdr_cycle=1000
#sgdr_mult=2
#steps=4000,6000,8000,9000
#scales=1, 1, 0.1, 0.1

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

# Downsample

[convolutional]
batch_normalize=1
filters=64
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=32
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=128
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=256
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=512
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

######################

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

### SPP ###
[maxpool]
stride=1
size=5

[route]
layers=-2

[maxpool]
stride=1
size=9

[route]
layers=-4

[maxpool]
stride=1
size=13

[route]
layers=-1,-3,-5,-6

### End SPP ###

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky


[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky



########### to [yolo-3]



[route]
layers = -4

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 61



[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky


########### to [yolo-2]




[route]
layers = -4

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 36



[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky



########### to [yolo-1]


########### features of different layers


[route]
layers=1

[reorg3d]
stride=2

[route]
layers=5,-1

[reorg3d]
stride=2

[route]
layers=12,-1

[reorg3d]
stride=2

[route]
layers=37,-1

[reorg3d]
stride=2

[route]
layers=62,-1



########### [yolo-1]

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=4

[route]
layers = -1,-12


[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=340
activation=linear


[yolo]
mask = 0,1,2,3
anchors = 8,8, 10,13, 16,30, 33,23,  32,32, 30,61, 62,45, 64,64,  59,119, 116,90, 156,198, 373,326
classes=80
num=12
jitter=.3
ignore_thresh = .7
truth_thresh = 1
scale_x_y = 1.05
random=0




########### [yolo-2]


[route]
layers = -7

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1,-28


[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=340
activation=linear


[yolo]
mask = 4,5,6,7
anchors = 8,8, 10,13, 16,30, 33,23,  32,32, 30,61, 62,45, 64,64,  59,119, 116,90, 156,198, 373,326
classes=80
num=12
jitter=.3
ignore_thresh = .7
truth_thresh = 1
scale_x_y = 1.1
random=0



########### [yolo-3]

[route]
layers = -14

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[route]
layers = -1,-43

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky


[convolutional]
size=1
stride=1
pad=1
filters=340
activation=linear


[yolo]
mask = 8,9,10,11
anchors = 8,8, 10,13, 16,30, 33,23,  32,32, 30,61, 62,45, 59,119,   80,80, 116,90, 156,198, 373,326
classes=80
num=12
jitter=.3
ignore_thresh = .7
truth_thresh = 1
scale_x_y = 1.2
random=0


================================================
FILE: cfg/yolov3/yolov3-spp.cfg
================================================
[net]
# Testing
# batch=1
# subdivisions=1
# Training
batch=64
subdivisions=16
width=608
height=608
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=1000
max_batches = 500200
policy=steps
steps=400000,450000
scales=.1,.1

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

# Downsample

[convolutional]
batch_normalize=1
filters=64
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=32
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=128
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=256
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
a
Download .txt
gitextract_flko7qgo/

├── EagleEye_normal_prune.py
├── EagleEye_regular_prune.py
├── EagleEye_slim_prune.py
├── LICENSE
├── PTQ.py
├── README.md
├── cfg/
│   ├── yolov2/
│   │   ├── yolov2-hand.cfg
│   │   ├── yolov2-tiny-hand.cfg
│   │   ├── yolov2-tiny.cfg
│   │   └── yolov2.cfg
│   ├── yolov3/
│   │   ├── yolov3-UAV.cfg
│   │   ├── yolov3-asff.cfg
│   │   ├── yolov3-bdd100k.cfg
│   │   ├── yolov3-hand.cfg
│   │   ├── yolov3-onDIOR.cfg
│   │   ├── yolov3-screw.cfg
│   │   ├── yolov3-ship.cfg
│   │   ├── yolov3-spp-matrix.cfg
│   │   ├── yolov3-spp-pan-scale.cfg
│   │   ├── yolov3-spp.cfg
│   │   ├── yolov3-spp3.cfg
│   │   ├── yolov3-visdrone.cfg
│   │   └── yolov3.cfg
│   ├── yolov3-ghostnet/
│   │   └── yolov3-ghost-coco.cfg
│   ├── yolov3-mobilenet/
│   │   ├── yolov3-mobilenet-UAV.cfg
│   │   ├── yolov3-mobilenet-coco.cfg
│   │   ├── yolov3-mobilenet-hand.cfg
│   │   ├── yolov3-mobilenet-screw.cfg
│   │   └── yolov3-mobilenet-visdrone.cfg
│   ├── yolov3-singlechannel/
│   │   └── yolov3-singlechannel.cfg
│   ├── yolov3tiny/
│   │   ├── yolov3-tiny-UAV.cfg
│   │   ├── yolov3-tiny-hand.cfg
│   │   ├── yolov3-tiny-ship-one.cfg
│   │   ├── yolov3-tiny-ship.cfg
│   │   ├── yolov3-tiny.cfg
│   │   ├── yolov3-tiny3.cfg
│   │   ├── yolov3-tiny_bdd100k.cfg
│   │   ├── yolov3-tiny_onDIOR.cfg
│   │   └── yolov3-tiny_visdrone.cfg
│   ├── yolov3tiny-efficientnetB0/
│   │   └── yolov3tiny-efficientnetB0.cfg
│   ├── yolov3tiny-mobilenet-small/
│   │   ├── yolov3tiny-mobilenet-small-UAV.cfg
│   │   ├── yolov3tiny-mobilenet-small-coco.cfg
│   │   ├── yolov3tiny-mobilenet-small-screw.cfg
│   │   └── yolov3tiny-mobilenet-small-visdrone.cfg
│   ├── yolov4/
│   │   ├── yolov4-hand.cfg
│   │   ├── yolov4-relu.cfg
│   │   ├── yolov4-visdrone.cfg
│   │   └── yolov4.cfg
│   └── yolov4tiny/
│       └── yolov4-tiny.cfg
├── convert.py
├── convert_FPGA.py
├── convert_FPGA_2.py
├── data/
│   ├── UAV_Samples_label.data
│   ├── UAV_Samples_label.names
│   ├── bdd100k.data
│   ├── bdd100k.names
│   ├── coco.names
│   ├── coco2014.data
│   ├── coco2017.data
│   ├── dior.data
│   ├── dior.names
│   ├── get_coco2014.sh
│   ├── get_coco2017.sh
│   ├── oxfordhand.data
│   ├── oxfordhand.names
│   ├── screw.data
│   ├── screw.names
│   ├── trainset.data
│   ├── trainset.names
│   ├── visdrone.data
│   └── visdrone.names
├── detect.py
├── info.py
├── layer_channel_prune.py
├── layer_channel_regular_prune.py
├── layer_prune.py
├── models.py
├── normal_prune.py
├── regular_prune.py
├── requirements.txt
├── shortcut_prune.py
├── slim_prune.py
├── test.py
├── train.py
├── utils/
│   ├── __init__.py
│   ├── adabound.py
│   ├── datasets.py
│   ├── gcp.sh
│   ├── google_utils.py
│   ├── layers.py
│   ├── output_upsample.py
│   ├── parse_config.py
│   ├── prune_utils.py
│   ├── quantized/
│   │   ├── __init__.py
│   │   ├── quantized_TPSQ.py
│   │   ├── quantized_dorefa.py
│   │   ├── quantized_google.py
│   │   ├── quantized_lowbit.py
│   │   ├── quantized_ptq.py
│   │   └── quantized_ptq_cos.py
│   ├── torch_utils.py
│   └── utils.py
└── weights/
    └── pretrain_weights/
        └── download_yolov3_weights.sh
Download .txt
SYMBOL INDEX (471 symbols across 33 files)

FILE: EagleEye_normal_prune.py
  function obtain_avg_forward_time (line 13) | def obtain_avg_forward_time(input, model, repeat=200):
  function obtain_filters_mask (line 24) | def obtain_filters_mask(model, CBL_idx, prune_idx, idx_mask):
  function obtain_l1_mask (line 59) | def obtain_l1_mask(conv_module, random_rate):
  function performance_summary (line 73) | def performance_summary(model, opt=None, prefix=""):
  function rand_prune_and_eval (line 78) | def rand_prune_and_eval(model, min_rate, max_rate):

FILE: EagleEye_regular_prune.py
  function obtain_avg_forward_time (line 10) | def obtain_avg_forward_time(input, model, repeat=200):
  function obtain_filters_mask (line 21) | def obtain_filters_mask(model, CBL_idx, prune_idx, idx_mask):
  function obtain_l1_mask (line 52) | def obtain_l1_mask(conv_module, random_rate):
  function performance_summary (line 68) | def performance_summary(model, opt=None, prefix=""):
  function rand_prune_and_eval (line 72) | def rand_prune_and_eval(model, min_rate, max_rate):

FILE: EagleEye_slim_prune.py
  function obtain_avg_forward_time (line 11) | def obtain_avg_forward_time(input, model, repeat=200):
  function obtain_filters_mask (line 22) | def obtain_filters_mask(model, CBL_idx, prune_idx, idx_mask):
  function obtain_l1_mask (line 51) | def obtain_l1_mask(conv_module, random_rate):
  function performance_summary (line 65) | def performance_summary(model, opt=None, prefix=""):
  function rand_prune_and_eval (line 69) | def rand_prune_and_eval(model, min_rate, max_rate):

FILE: PTQ.py
  function PTQ (line 12) | def PTQ(cfg,

FILE: convert.py
  function convert (line 10) | def convert():

FILE: convert_FPGA.py
  function convert (line 9) | def convert():

FILE: convert_FPGA_2.py
  function convert (line 9) | def convert():

FILE: detect.py
  function detect (line 9) | def detect(save_img=False):

FILE: layer_channel_prune.py
  function obtain_filters_mask (line 13) | def obtain_filters_mask(model, thre, CBL_idx, prune_idx):
  function prune_and_eval (line 50) | def prune_and_eval(model, CBL_idx, CBLidx2mask):
  function prune_and_eval2 (line 64) | def prune_and_eval2(model, prune_shortcuts=[]):
  function obtain_filters_mask2 (line 80) | def obtain_filters_mask2(model, CBL_idx, prune_shortcuts):
  function obtain_avg_forward_time (line 95) | def obtain_avg_forward_time(input, model, repeat=200):

FILE: layer_channel_regular_prune.py
  function obtain_filters_mask (line 15) | def obtain_filters_mask(model, thre, CBL_idx, shortcut_idx, prune_idx):
  function prune_and_eval (line 86) | def prune_and_eval(model, sorted_bn, shortcut_idx, percent=.0):
  function prune_and_eval2 (line 131) | def prune_and_eval2(model, prune_shortcuts=[]):
  function obtain_filters_mask2 (line 147) | def obtain_filters_mask2(model, CBL_idx, prune_shortcuts):
  function obtain_avg_forward_time (line 162) | def obtain_avg_forward_time(input, model, repeat=200):

FILE: layer_prune.py
  function prune_and_eval (line 14) | def prune_and_eval(model, prune_shortcuts=[]):
  function obtain_filters_mask (line 30) | def obtain_filters_mask(model, CBL_idx, prune_shortcuts):
  function obtain_avg_forward_time (line 45) | def obtain_avg_forward_time(input, model, repeat=200):

FILE: models.py
  function create_modules (line 11) | def create_modules(module_defs, img_size, cfg, quantized, quantizer_outp...
  class YOLOLayer (line 350) | class YOLOLayer(nn.Module):
    method __init__ (line 351) | def __init__(self, anchors, nc, img_size, yolo_index, layers, stride, ...
    method create_grids (line 367) | def create_grids(self, ng=(13, 13), device='cpu'):
    method forward (line 380) | def forward(self, p, out):
  class Darknet (line 440) | class Darknet(nn.Module):
    method __init__ (line 443) | def __init__(self, cfg, img_size=(416, 416), verbose=False, quantized=...
    method forward (line 478) | def forward(self, x, augment=False):
    method forward_once (line 508) | def forward_once(self, x, augment=False, verbose=False):
    method fuse (line 563) | def fuse(self):
    method info (line 579) | def info(self, verbose=False):
  function get_yolo_layers (line 583) | def get_yolo_layers(model):
  function load_darknet_weights (line 587) | def load_darknet_weights(self, weights, cutoff=-1, pt=False, quant=False):
  function save_weights (line 738) | def save_weights(self, path='model.weights', cutoff=-1):
  function convert (line 785) | def convert(cfg='cfg/yolov3-spp.cfg', weights='weights/yolov3-spp.weight...
  function attempt_download (line 816) | def attempt_download(weights):

FILE: normal_prune.py
  function prune_and_eval (line 15) | def prune_and_eval(model, sorted_bn, percent=.0):
  function obtain_filters_mask (line 41) | def obtain_filters_mask(model, thre, CBL_idx, prune_idx):
  function obtain_avg_forward_time (line 76) | def obtain_avg_forward_time(input, model, repeat=200):

FILE: regular_prune.py
  function prune_and_eval (line 23) | def prune_and_eval(model, sorted_bn, percent=.0):
  function obtain_filters_mask (line 68) | def obtain_filters_mask(model, thre, CBL_idx, prune_idx):
  function obtain_avg_forward_time (line 124) | def obtain_avg_forward_time(input, model, repeat=200):

FILE: shortcut_prune.py
  function prune_and_eval (line 28) | def prune_and_eval(model, sorted_bn, shortcut_idx, percent=.0):
  function obtain_filters_mask (line 73) | def obtain_filters_mask(model, thre, CBL_idx, shortcut_idx, prune_idx):
  function obtain_avg_forward_time (line 124) | def obtain_avg_forward_time(input, model, repeat=200):

FILE: slim_prune.py
  function obtain_filters_mask (line 13) | def obtain_filters_mask(model, thre, CBL_idx, prune_idx):
  function prune_and_eval (line 50) | def prune_and_eval(model, CBL_idx, CBLidx2mask):
  function obtain_avg_forward_time (line 64) | def obtain_avg_forward_time(input, model, repeat=200):

FILE: test.py
  function test (line 10) | def test(cfg,

FILE: train.py
  function train (line 56) | def train(hyp):

FILE: utils/adabound.py
  class AdaBound (line 7) | class AdaBound(Optimizer):
    method __init__ (line 26) | def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), final_lr=0.1, ...
    method __setstate__ (line 46) | def __setstate__(self, state):
    method step (line 51) | def step(self, closure=None):
  class AdaBoundW (line 122) | class AdaBoundW(Optimizer):
    method __init__ (line 141) | def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), final_lr=0.1, ...
    method __setstate__ (line 161) | def __setstate__(self, state):
    method step (line 166) | def step(self, closure=None):

FILE: utils/datasets.py
  function exif_size (line 28) | def exif_size(img):
  class LoadImages (line 43) | class LoadImages:  # for inference
    method __init__ (line 44) | def __init__(self, path, img_size=416, is_gray_scale=False, rect=False):
    method __iter__ (line 69) | def __iter__(self):
    method __next__ (line 73) | def __next__(self):
    method new_video (line 118) | def new_video(self, path):
    method __len__ (line 123) | def __len__(self):
  class LoadWebcam (line 127) | class LoadWebcam:  # for inference
    method __init__ (line 128) | def __init__(self, pipe=0, img_size=416):
    method __iter__ (line 149) | def __iter__(self):
    method __next__ (line 153) | def __next__(self):
    method __len__ (line 188) | def __len__(self):
  class LoadStreams (line 192) | class LoadStreams:  # multiple IP or RTSP cameras
    method __init__ (line 193) | def __init__(self, sources='streams.txt', img_size=416):
    method update (line 226) | def update(self, index, cap):
    method __iter__ (line 238) | def __iter__(self):
    method __next__ (line 242) | def __next__(self):
    method __len__ (line 261) | def __len__(self):
  class LoadImagesAndLabels (line 265) | class LoadImagesAndLabels(Dataset):  # for training/testing
    method __init__ (line 266) | def __init__(self, path, img_size=416, batch_size=16, augment=False, h...
    method __len__ (line 410) | def __len__(self):
    method __getitem__ (line 419) | def __getitem__(self, index):
    method collate_fn (line 504) | def collate_fn(batch):
  function load_image (line 511) | def load_image(self, index, is_gray_scale=False):
  function augment_hsv (line 534) | def augment_hsv(img, hgain=0.5, sgain=0.5, vgain=0.5):
  function load_mosaic (line 553) | def load_mosaic(self, index, is_gray_scale=False):
  function letterbox (line 611) | def letterbox(img, new_shape=(416, 416), color=(114, 114, 114), auto=Tru...
  function random_affine (line 649) | def random_affine(img, targets=(), degrees=10, translate=.1, scale=.1, s...
  function cutout (line 718) | def cutout(image, labels):
  class FenceMask (line 831) | class FenceMask(torch.nn.Module):
    method __init__ (line 832) | def __init__(self, batch_size, img_size, probability):
    method forward (line 881) | def forward(self, x):
    method set_prob (line 903) | def set_prob(self, epoch, max_epoch):
  class Grid (line 907) | class Grid(object):
    method __init__ (line 908) | def __init__(self, d1, d2, rotate=1, ratio=0.5, mode=0, prob=1.):
    method set_prob (line 916) | def set_prob(self, epoch, max_epoch):
    method __call__ (line 919) | def __call__(self, img):
  class GridMask (line 968) | class GridMask(torch.nn.Module):
    method __init__ (line 969) | def __init__(self, d1, d2, rotate=1, ratio=0.5, mode=0, prob=1.):
    method set_prob (line 977) | def set_prob(self, epoch, max_epoch):
    method forward (line 980) | def forward(self, x):
  function reduce_img_size (line 991) | def reduce_img_size(path='../data/sm4/images', img_size=1024):  # from u...
  function convert_images2bmp (line 1008) | def convert_images2bmp():  # from utils.datasets import *; convert_image...
  function recursive_dataset2bmp (line 1032) | def recursive_dataset2bmp(dataset='../data/sm4_bmp'):  # from utils.data...
  function imagelist2folder (line 1052) | def imagelist2folder(path='data/coco_64img.txt'):  # from utils.datasets...
  function create_folder (line 1061) | def create_folder(path='./new_folder'):

FILE: utils/google_utils.py
  function gdrive_download (line 11) | def gdrive_download(id='1HaXkef9z6y5l4vUnCYgdmEAj61c6bfWO', name='coco.z...
  function upload_blob (line 47) | def upload_blob(bucket_name, source_file_name, destination_blob_name):
  function download_blob (line 62) | def download_blob(bucket_name, source_blob_name, destination_file_name):

FILE: utils/layers.py
  function make_divisible (line 4) | def make_divisible(v, divisor):
  class Flatten (line 10) | class Flatten(nn.Module):
    method forward (line 12) | def forward(self, x):
  class Concat (line 16) | class Concat(nn.Module):
    method __init__ (line 18) | def __init__(self, dimension=1):
    method forward (line 22) | def forward(self, x):
  class FeatureConcat (line 26) | class FeatureConcat(nn.Module):
    method __init__ (line 27) | def __init__(self, layers, groups):
    method forward (line 33) | def forward(self, x, outputs):
  class Shortcut (line 43) | class Shortcut(nn.Module):  # weighted sum of 2 or more layers https://a...
    method __init__ (line 44) | def __init__(self, layers, weight=False):
    method forward (line 52) | def forward(self, x, outputs):
  class MixConv2d (line 75) | class MixConv2d(nn.Module):  # MixConv: Mixed Depthwise Convolutional Ke...
    method __init__ (line 76) | def __init__(self, in_ch, out_ch, k=(3, 5, 7), stride=1, dilation=1, b...
    method forward (line 99) | def forward(self, x):
  class SwishImplementation (line 104) | class SwishImplementation(torch.autograd.Function):
    method forward (line 106) | def forward(ctx, x):
    method backward (line 111) | def backward(ctx, grad_output):
  class MishImplementation (line 117) | class MishImplementation(torch.autograd.Function):
    method forward (line 119) | def forward(ctx, x):
    method backward (line 124) | def backward(ctx, grad_output):
  class MemoryEfficientSwish (line 131) | class MemoryEfficientSwish(nn.Module):
    method forward (line 132) | def forward(self, x):
  class MemoryEfficientMish (line 136) | class MemoryEfficientMish(nn.Module):
    method forward (line 137) | def forward(self, x):
  class Swish (line 141) | class Swish(nn.Module):
    method forward (line 142) | def forward(self, x):
  class Mish (line 146) | class Mish(nn.Module):  # https://github.com/digantamisra98/Mish
    method forward (line 147) | def forward(self, x):
  class ReLU6 (line 151) | class ReLU6(nn.Module):
    method __init__ (line 152) | def __init__(self):
    method forward (line 155) | def forward(self, x):
  class HardSwish (line 159) | class HardSwish(nn.Module):
    method __init__ (line 160) | def __init__(self):
    method forward (line 163) | def forward(self, x):
  class HardSigmoid (line 167) | class HardSigmoid(nn.Module):
    method __init__ (line 168) | def __init__(self):
    method forward (line 171) | def forward(self, x):
  class SE (line 176) | class SE(nn.Module):
    method __init__ (line 177) | def __init__(self, channel, reduction=4):
    method forward (line 188) | def forward(self, x):

FILE: utils/output_upsample.py
  function Val_upsample (line 9) | def Val_upsample(cfg,TN):

FILE: utils/parse_config.py
  function parse_model_cfg (line 6) | def parse_model_cfg(path):
  function parse_data_cfg (line 54) | def parse_data_cfg(path):

FILE: utils/prune_utils.py
  function parse_module_defs2 (line 8) | def parse_module_defs2(module_defs):
  function parse_module_defs (line 53) | def parse_module_defs(module_defs):
  function parse_module_defs4 (line 91) | def parse_module_defs4(module_defs):
  function gather_bn_weights (line 107) | def gather_bn_weights(module_list, prune_idx):
  function write_cfg (line 119) | def write_cfg(cfg_file, module_defs):
  class BNOptimizer (line 130) | class BNOptimizer():
    method updateBN (line 133) | def updateBN(sr_flag, module_list, s, prune_idx):
  function obtain_quantiles (line 141) | def obtain_quantiles(bn_weights, num_quantile=5):
  function get_input_mask (line 155) | def get_input_mask(module_defs, idx, CBLidx2mask, is_gray_scale=False):
  function init_weights_from_loose_model (line 212) | def init_weights_from_loose_model(compact_model, loose_model, CBL_idx, O...
  function prune_model_keep_size (line 261) | def prune_model_keep_size(model, prune_idx, CBL_idx, CBLidx2mask):
  function obtain_bn_mask (line 338) | def obtain_bn_mask(bn_module, thre):
  function get_nearest_multiple (line 345) | def get_nearest_multiple(num, base):
  function merge_mask (line 355) | def merge_mask(model, CBLidx2mask, CBLidx2filters, base=1):
  function update_activation (line 422) | def update_activation(i, pruned_model, activation, CBL_idx):
  function prune_model_keep_size_forEagleEye (line 435) | def prune_model_keep_size_forEagleEye(model, prune_idx, CBLidx2mask):

FILE: utils/quantized/quantized_TPSQ.py
  class Round (line 15) | class Round(Function):
    method forward (line 18) | def forward(self, input):
    method backward (line 24) | def backward(self, grad_output):
  class Search_Pow2 (line 29) | class Search_Pow2(Function):
    method forward (line 32) | def forward(self, input):
    method backward (line 48) | def backward(self, grad_output):
  class Quantizer (line 66) | class Quantizer(nn.Module):
    method __init__ (line 67) | def __init__(self, bits, out_channels, warmup=False):
    method clamp (line 79) | def clamp(self, input):
    method quantize (line 89) | def quantize(self, input):
    method round (line 95) | def round(self, input):
    method dequantize (line 100) | def dequantize(self, input):
    method forward (line 106) | def forward(self, input):
    method get_quantize_value (line 120) | def get_quantize_value(self, input):
  class RangeTracker (line 133) | class RangeTracker(nn.Module):
    method __init__ (line 134) | def __init__(self):
    method update_range (line 137) | def update_range(self, min_val, max_val):
    method forward (line 141) | def forward(self, input):
  class GlobalRangeTracker (line 147) | class GlobalRangeTracker(RangeTracker):  # W,min_max_shape=(N, 1, 1, 1),...
    method __init__ (line 148) | def __init__(self):
    method update_range (line 154) | def update_range(self, min_val, max_val):
  class Bias_Quantizer (line 166) | class Bias_Quantizer(nn.Module):
    method __init__ (line 167) | def __init__(self, bits, range_tracker):
    method update_params (line 173) | def update_params(self):
    method quantize (line 189) | def quantize(self, input):
    method round (line 193) | def round(self, input):
    method clamp (line 198) | def clamp(self, input):
    method dequantize (line 205) | def dequantize(self, input):
    method forward (line 209) | def forward(self, input):
    method get_quantize_value (line 225) | def get_quantize_value(self, input):
    method get_scale (line 238) | def get_scale(self):
  class Weight_Quantizer (line 245) | class Weight_Quantizer(Quantizer):
    method __init__ (line 246) | def __init__(self, bits, out_channels, warmup):
    method forward (line 255) | def forward(self, input):
  class Activattion_Quantizer (line 290) | class Activattion_Quantizer(Quantizer):
    method __init__ (line 291) | def __init__(self, bits, out_channels, warmup):
    method forward (line 300) | def forward(self, input):
  function reshape_to_activation (line 336) | def reshape_to_activation(input):
  function reshape_to_weight (line 340) | def reshape_to_weight(input):
  function reshape_to_bias (line 344) | def reshape_to_bias(input):
  class TPSQ_BNFold_QuantizedConv2d_For_FPGA (line 349) | class TPSQ_BNFold_QuantizedConv2d_For_FPGA(nn.Conv2d):
    method __init__ (line 350) | def __init__(
    method forward (line 404) | def forward(self, input):
    method BN_fuse (line 574) | def BN_fuse(self):

FILE: utils/quantized/quantized_dorefa.py
  class Round (line 14) | class Round(Function):
    method forward (line 17) | def forward(self, input):
    method backward (line 23) | def backward(self, grad_output):
  class activation_quantize (line 29) | class activation_quantize(nn.Module):
    method __init__ (line 30) | def __init__(self, a_bits):
    method round (line 34) | def round(self, input):
    method get_quantize_value (line 38) | def get_quantize_value(self, input):
    method get_scale (line 47) | def get_scale(self):
    method forward (line 54) | def forward(self, input):
  class weight_quantize (line 70) | class weight_quantize(nn.Module):
    method __init__ (line 71) | def __init__(self, w_bits):
    method round (line 75) | def round(self, input):
    method get_quantize_value (line 79) | def get_quantize_value(self, input):
    method get_scale (line 90) | def get_scale(self):
    method forward (line 97) | def forward(self, input):
    method get_weights (line 113) | def get_weights(self, input):
  class DorefaConv2d (line 129) | class DorefaConv2d(nn.Conv2d):
    method __init__ (line 130) | def __init__(
    method forward (line 157) | def forward(self, input):
  function reshape_to_activation (line 175) | def reshape_to_activation(input):
  function reshape_to_weight (line 179) | def reshape_to_weight(input):
  function reshape_to_bias (line 183) | def reshape_to_bias(input):
  class BNFold_DorefaConv2d (line 187) | class BNFold_DorefaConv2d(DorefaConv2d):
    method __init__ (line 189) | def __init__(
    method forward (line 242) | def forward(self, input):
    method BN_fuse (line 427) | def BN_fuse(self):
  class DorefaLinear (line 445) | class DorefaLinear(nn.Linear):
    method __init__ (line 446) | def __init__(self, in_features, out_features, bias=True, a_bits=2, w_b...
    method forward (line 451) | def forward(self, input):

FILE: utils/quantized/quantized_google.py
  class RangeTracker (line 16) | class RangeTracker(nn.Module):
    method __init__ (line 17) | def __init__(self, q_level):
    method update_range (line 21) | def update_range(self, min_val, max_val):
    method forward (line 25) | def forward(self, input):
  class GlobalRangeTracker (line 35) | class GlobalRangeTracker(RangeTracker):  # W,min_max_shape=(N, 1, 1, 1),...
    method __init__ (line 36) | def __init__(self, q_level, out_channels):
    method update_range (line 46) | def update_range(self, min_val, max_val):
  class AveragedRangeTracker (line 58) | class AveragedRangeTracker(RangeTracker):  # A,min_max_shape=(1, 1, 1, 1...
    method __init__ (line 59) | def __init__(self, q_level, out_channels, momentum=0.1):
    method update_range (line 70) | def update_range(self, min_val, max_val):
  class Round (line 81) | class Round(Function):
    method forward (line 84) | def forward(self, input):
    method backward (line 90) | def backward(self, grad_output):
  class Quantizer (line 95) | class Quantizer(nn.Module):
    method __init__ (line 96) | def __init__(self, bits, range_tracker, out_channels, Scale_freeze_ste...
    method update_params (line 110) | def update_params(self):
    method quantize (line 114) | def quantize(self, input):
    method round (line 118) | def round(self, input):
    method clamp (line 123) | def clamp(self, input):
    method dequantize (line 134) | def dequantize(self, input):
    method forward (line 138) | def forward(self, input):
    method get_quantize_value (line 155) | def get_quantize_value(self, input):
    method get_scale (line 168) | def get_scale(self):
  class SymmetricQuantizer (line 176) | class SymmetricQuantizer(Quantizer):
    method update_params (line 178) | def update_params(self):
  class AsymmetricQuantizer (line 200) | class AsymmetricQuantizer(Quantizer):
    method update_params (line 202) | def update_params(self):
  function reshape_to_activation (line 222) | def reshape_to_activation(input):
  function reshape_to_weight (line 226) | def reshape_to_weight(input):
  function reshape_to_bias (line 230) | def reshape_to_bias(input):
  class BNFold_QuantizedConv2d_For_FPGA (line 235) | class BNFold_QuantizedConv2d_For_FPGA(nn.Conv2d):
    method __init__ (line 236) | def __init__(
    method forward (line 320) | def forward(self, input):
    method BN_fuse (line 821) | def BN_fuse(self):
  class QuantizedShortcut_max (line 839) | class QuantizedShortcut_max(nn.Module):  # weighted sum of 2 or more lay...
    method __init__ (line 840) | def __init__(self, layers, weight=False, bits=8,
    method quantize (line 863) | def quantize(self, input):
    method round (line 867) | def round(self, input):
    method clamp (line 872) | def clamp(self, input):
    method dequantize (line 879) | def dequantize(self, input):
    method forward (line 883) | def forward(self, x, outputs):
  class QuantizedShortcut_min (line 1066) | class QuantizedShortcut_min(nn.Module):  # weighted sum of 2 or more lay...
    method __init__ (line 1067) | def __init__(self, layers, weight=False, bits=8,
    method quantize (line 1091) | def quantize(self, input, featrure_in=False):
    method round (line 1098) | def round(self, input):
    method clamp (line 1103) | def clamp(self, input):
    method dequantize (line 1110) | def dequantize(self, input, featrure_in=False):
    method forward (line 1117) | def forward(self, x, outputs):
  class QuantizedFeatureConcat (line 1305) | class QuantizedFeatureConcat(nn.Module):
    method __init__ (line 1306) | def __init__(self, layers, groups, bits=8,
    method quantize (line 1324) | def quantize(self, input):
    method round (line 1328) | def round(self, input):
    method clamp (line 1333) | def clamp(self, input):
    method dequantize (line 1340) | def dequantize(self, input):
    method forward (line 1344) | def forward(self, x, outputs):

FILE: utils/quantized/quantized_lowbit.py
  class Ternarize (line 10) | class Ternarize(Function):
    method forward (line 17) | def forward(self, input):
    method backward (line 33) | def backward(self, grad_output):
  class Binarize (line 42) | class Binarize(Function):
    method forward (line 44) | def forward(self, input):
    method backward (line 52) | def backward(self, grad_output):
  class BinaryLeakyReLU (line 66) | class BinaryLeakyReLU(nn.LeakyReLU):
    method __init__ (line 67) | def __init__(self):
    method forward (line 70) | def forward(self, input):
  class BinaryLinear (line 76) | class BinaryLinear(nn.Linear):
    method forward (line 78) | def forward(self, input):
    method reset_parameters (line 85) | def reset_parameters(self):
  class BWNConv2d (line 97) | class BWNConv2d(nn.Conv2d):
    method forward (line 99) | def forward(self, input):
    method reset_parameters (line 106) | def reset_parameters(self):
  class BinaryConv2d (line 122) | class BinaryConv2d(nn.Conv2d):
    method forward (line 124) | def forward(self, input):
    method reset_parameters (line 130) | def reset_parameters(self):

FILE: utils/quantized/quantized_ptq.py
  class RangeTracker (line 15) | class RangeTracker(nn.Module):
    method __init__ (line 16) | def __init__(self, q_level):
    method update_range (line 20) | def update_range(self, min_val, max_val):
    method forward (line 24) | def forward(self, input):
  class GlobalRangeTracker (line 34) | class GlobalRangeTracker(RangeTracker):  # W,min_max_shape=(N, 1, 1, 1),...
    method __init__ (line 35) | def __init__(self, q_level, out_channels):
    method update_range (line 45) | def update_range(self, min_val, max_val):
  class AveragedRangeTracker (line 57) | class AveragedRangeTracker(RangeTracker):  # A,min_max_shape=(1, 1, 1, 1...
    method __init__ (line 58) | def __init__(self, q_level, out_channels, momentum=0.1):
    method update_range (line 69) | def update_range(self, min_val, max_val):
  class Round (line 80) | class Round(Function):
    method forward (line 83) | def forward(self, input):
  class Quantizer (line 89) | class Quantizer(nn.Module):
    method __init__ (line 90) | def __init__(self, bits, range_tracker, out_channels, FPGA, sign=True):
    method update_params (line 103) | def update_params(self):
    method quantize (line 107) | def quantize(self, input):
    method round (line 111) | def round(self, input):
    method clamp (line 116) | def clamp(self, input):
    method dequantize (line 127) | def dequantize(self, input):
    method forward (line 131) | def forward(self, input):
    method get_quantize_value (line 147) | def get_quantize_value(self, input):
    method get_scale (line 160) | def get_scale(self):
  class SymmetricQuantizer (line 168) | class SymmetricQuantizer(Quantizer):
    method update_params (line 170) | def update_params(self):
  class AsymmetricQuantizer (line 194) | class AsymmetricQuantizer(Quantizer):
    method update_params (line 196) | def update_params(self):
  class PTQuantizedConv2d (line 219) | class PTQuantizedConv2d(nn.Conv2d):
    method __init__ (line 220) | def __init__(
    method forward (line 260) | def forward(self, input):
  function reshape_to_activation (line 278) | def reshape_to_activation(input):
  function reshape_to_weight (line 282) | def reshape_to_weight(input):
  function reshape_to_bias (line 286) | def reshape_to_bias(input):
  class BNFold_PTQuantizedConv2d_For_FPGA (line 293) | class BNFold_PTQuantizedConv2d_For_FPGA(PTQuantizedConv2d):
    method __init__ (line 294) | def __init__(
    method forward (line 369) | def forward(self, input):
    method BN_fuse (line 813) | def BN_fuse(self):

FILE: utils/quantized/quantized_ptq_cos.py
  class Round (line 14) | class Round(Function):
    method forward (line 17) | def forward(self, input):
  class Quantizer (line 23) | class Quantizer(nn.Module):
    method __init__ (line 24) | def __init__(self, bits, out_channels):
    method update_params (line 35) | def update_params(self, step):
    method quantize (line 44) | def quantize(self, input):
    method round (line 48) | def round(self, input):
    method clamp (line 53) | def clamp(self, input):
    method dequantize (line 60) | def dequantize(self, input):
    method forward (line 64) | def forward(self, input):
    method get_quantize_value (line 95) | def get_quantize_value(self, input):
    method get_scale (line 109) | def get_scale(self):
  function reshape_to_activation (line 116) | def reshape_to_activation(input):
  function reshape_to_weight (line 120) | def reshape_to_weight(input):
  function reshape_to_bias (line 124) | def reshape_to_bias(input):
  class BNFold_COSPTQuantizedConv2d_For_FPGA (line 131) | class BNFold_COSPTQuantizedConv2d_For_FPGA(nn.Conv2d):
    method __init__ (line 132) | def __init__(
    method forward (line 193) | def forward(self, input):
    method BN_fuse (line 723) | def BN_fuse(self):
  class COSPTQuantizedShortcut_min (line 741) | class COSPTQuantizedShortcut_min(nn.Module):  # weighted sum of 2 or mor...
    method __init__ (line 742) | def __init__(self, layers, weight=False, bits=8,
    method quantize (line 773) | def quantize(self, input, type):
    method round (line 782) | def round(self, input):
    method clamp (line 787) | def clamp(self, input):
    method dequantize (line 794) | def dequantize(self, input, type):
    method update_params (line 804) | def update_params(self, step, type):
    method forward (line 821) | def forward(self, x, outputs):
  class COSPTQuantizedShortcut_max (line 1058) | class COSPTQuantizedShortcut_max(nn.Module):  # weighted sum of 2 or mor...
    method __init__ (line 1059) | def __init__(self, layers, weight=False, bits=8,
    method quantize (line 1088) | def quantize(self, input, type):
    method round (line 1097) | def round(self, input):
    method clamp (line 1102) | def clamp(self, input):
    method dequantize (line 1109) | def dequantize(self, input, type):
    method update_params (line 1119) | def update_params(self, step, type):
    method forward (line 1136) | def forward(self, x, outputs):
  class COSPTQuantizedFeatureConcat (line 1364) | class COSPTQuantizedFeatureConcat(nn.Module):
    method __init__ (line 1365) | def __init__(self, layers, groups, bits=8,
    method quantize (line 1383) | def quantize(self, input):
    method round (line 1387) | def round(self, input):
    method clamp (line 1392) | def clamp(self, input):
    method dequantize (line 1399) | def dequantize(self, input):
    method forward (line 1403) | def forward(self, x, outputs):

FILE: utils/torch_utils.py
  function init_seeds (line 7) | def init_seeds(seed=0):
  function select_device (line 16) | def select_device(device='', batch_size=None):
  function time_synchronized (line 43) | def time_synchronized():
  function initialize_weights (line 48) | def initialize_weights(model):
  function find_modules (line 60) | def find_modules(model, mclass=nn.Conv2d):
  function fuse_conv_and_bn (line 65) | def fuse_conv_and_bn(conv, bn):
  function model_info (line 92) | def model_info(model, verbose=False):
  function load_classifier (line 113) | def load_classifier(name='resnet101', n=2):
  function scale_img (line 130) | def scale_img(img, ratio=1.0, same_shape=True):  # img(16,3,256,416), r=...
  class ModelEMA (line 141) | class ModelEMA:
    method __init__ (line 159) | def __init__(self, model, decay=0.9999, device=''):
    method update (line 171) | def update(self, model):
    method update_attr (line 185) | def update_attr(self, model):

FILE: utils/utils.py
  function init_seeds (line 31) | def init_seeds(seed=0):
  function load_classes (line 37) | def load_classes(path):
  function labels_to_class_weights (line 44) | def labels_to_class_weights(labels, nc=80):
  function labels_to_image_weights (line 63) | def labels_to_image_weights(labels, nc=80, class_weights=np.ones(80)):
  function coco_class_weights (line 72) | def coco_class_weights():  # frequency of each class in coco train2014
  function coco80_to_coco91_class (line 86) | def coco80_to_coco91_class():  # converts 80-index (val2014) to 91-index...
  function xyxy2xywh (line 98) | def xyxy2xywh(x):
  function xywh2xyxy (line 108) | def xywh2xyxy(x):
  function scale_coords (line 138) | def scale_coords(img1_shape, coords, img0_shape, ratio_pad=None):
  function clip_coords (line 154) | def clip_coords(boxes, img_shape):
  function ap_per_class (line 162) | def ap_per_class(tp, conf, pred_cls, target_cls):
  function compute_ap (line 225) | def compute_ap(recall, precision):
  function bbox_iou (line 254) | def bbox_iou(box1, box2, x1y1x2y2=True, GIoU=False, DIoU=False, CIoU=Fal...
  function box_iou (line 300) | def box_iou(box1, box2):
  function wh_iou (line 325) | def wh_iou(wh1, wh2):
  class FocalLoss (line 333) | class FocalLoss(nn.Module):
    method __init__ (line 335) | def __init__(self, loss_fcn, gamma=1.5, alpha=0.25):
    method forward (line 343) | def forward(self, pred, true):
  function smooth_BCE (line 363) | def smooth_BCE(eps=0.1):  # https://github.com/ultralytics/yolov3/issues...
  function compute_loss (line 368) | def compute_loss(p, targets, model):  # predictions, targets, model
  function compute_lost_KD (line 435) | def compute_lost_KD(output_s, output_t, num_classes, batch_size):
  function compute_lost_KD2 (line 446) | def compute_lost_KD2(model, targets, output_s, output_t):
  function compute_lost_KD3 (line 490) | def compute_lost_KD3(model, targets, output_s, output_t):
  function compute_lost_KD4 (line 524) | def compute_lost_KD4(model, targets, output_s, output_t, feature_s, feat...
  function indices_merge (line 567) | def indices_merge(indices):
  function fine_grained_imitation_feature_mask (line 578) | def fine_grained_imitation_feature_mask(feature_s, feature_t, indices, i...
  function compute_lost_KD5 (line 607) | def compute_lost_KD5(model, targets, output_s, output_t, feature_s, feat...
  function fine_grained_imitation_mask (line 657) | def fine_grained_imitation_mask(feature_s, feature_t, indices):
  function compute_lost_KD6 (line 671) | def compute_lost_KD6(model, targets, output_s, output_t, batch_size):
  function Failure_Case_Loss_FM (line 692) | def Failure_Case_Loss_FM(masks, imgs, targets):
  function build_targets (line 725) | def build_targets(p, targets, model):
  function non_max_suppression (line 782) | def non_max_suppression(prediction, conf_thres=0.1, iou_thres=0.6, multi...
  function get_yolo_layers (line 863) | def get_yolo_layers(model):
  function print_model_biases (line 868) | def print_model_biases(model):
  function strip_optimizer (line 887) | def strip_optimizer(f='weights/last.pt'):  # from utils.utils import *; ...
  function create_backbone (line 894) | def create_backbone(f='weights/last.pt'):  # from utils.utils import *; ...
  function coco_class_count (line 908) | def coco_class_count(path='../coco/labels/train2014/'):
  function coco_only_people (line 919) | def coco_only_people(path='../coco/labels/train2017/'):  # from utils.ut...
  function select_best_evolve (line 928) | def select_best_evolve(path='evolve*.txt'):  # from utils.utils import *...
  function crop_images_random (line 935) | def crop_images_random(path='../images/', scale=0.50):  # from utils.uti...
  function coco_single_class_labels (line 958) | def coco_single_class_labels(path='../coco/labels/train2014/', label_cla...
  function kmean_anchors (line 980) | def kmean_anchors(path='./data/coco64.txt', n=9, img_size=(320, 1024), t...
  function print_mutation (line 1059) | def print_mutation(hyp, results, bucket=''):
  function apply_classifier (line 1078) | def apply_classifier(x, model, img, im0):
  function fitness (line 1113) | def fitness(x):
  function output_to_target (line 1119) | def output_to_target(output, width, height):
  function plot_one_box (line 1149) | def plot_one_box(x, img, color=None, label=None, line_thickness=None):
  function plot_wh_methods (line 1163) | def plot_wh_methods():  # from utils.utils import *; plot_wh_methods()
  function plot_images (line 1183) | def plot_images(images, targets, paths=None, fname='images.jpg', names=N...
  function plot_test_txt (line 1265) | def plot_test_txt():  # from utils.utils import *; plot_test()
  function plot_targets_txt (line 1284) | def plot_targets_txt():  # from utils.utils import *; plot_targets_txt()
  function plot_evolution_results (line 1298) | def plot_evolution_results(hyp):  # from utils.utils import *; plot_evol...
  function plot_results_overlay (line 1318) | def plot_results_overlay(start=0, stop=0):  # from utils.utils import *;...
  function plot_results (line 1341) | def plot_results(start=0, stop=0, bucket='', id=()):  # from utils.utils...
Condensed preview — 103 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,061K chars).
[
  {
    "path": "EagleEye_normal_prune.py",
    "chars": 14496,
    "preview": "from sys import float_repr_style\nfrom models import *\nfrom utils.utils import *\nfrom utils.prune_utils import *\nfrom uti"
  },
  {
    "path": "EagleEye_regular_prune.py",
    "chars": 14538,
    "preview": "from models import *\nfrom utils.utils import *\nfrom utils.prune_utils import *\nfrom utils.datasets import *\nimport os\nim"
  },
  {
    "path": "EagleEye_slim_prune.py",
    "chars": 14177,
    "preview": "from models import *\nfrom utils.utils import *\nfrom utils.prune_utils import *\nfrom utils.datasets import *\nimport os\nim"
  },
  {
    "path": "LICENSE",
    "chars": 35149,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "PTQ.py",
    "chars": 6207,
    "preview": "import argparse\nimport test\nfrom torch.utils.data import DataLoader\nfrom models import *\nfrom utils.datasets import *\nfr"
  },
  {
    "path": "README.md",
    "chars": 18971,
    "preview": "# YOLOv3-ModelCompression-MultidatasetTraining\n\nThis project mainly include three parts.\n\n1.Provides training methods fo"
  },
  {
    "path": "cfg/yolov2/yolov2-hand.cfg",
    "chars": 2764,
    "preview": "[net]\n# Testing\nbatch = 1\nsubdivisions = 1\n# Training\n# batch=64\n# subdivisions=8\nwidth = 608\nheight = 608\nchannels = 3\n"
  },
  {
    "path": "cfg/yolov2/yolov2-tiny-hand.cfg",
    "chars": 1466,
    "preview": "[net]\nbatch = 64\nsubdivisions = 8\nwidth = 416\nheight = 416\nchannels = 3\nmomentum = 0.9\ndecay = 0.0005\nangle = 0\nsaturati"
  },
  {
    "path": "cfg/yolov2/yolov2-tiny.cfg",
    "chars": 1471,
    "preview": "[net]\nbatch = 64\nsubdivisions = 8\nwidth = 416\nheight = 416\nchannels = 3\nmomentum = 0.9\ndecay = 0.0005\nangle = 0\nsaturati"
  },
  {
    "path": "cfg/yolov2/yolov2.cfg",
    "chars": 2769,
    "preview": "[net]\n# Testing\nbatch = 1\nsubdivisions = 1\n# Training\n# batch=64\n# subdivisions=8\nwidth = 608\nheight = 608\nchannels = 3\n"
  },
  {
    "path": "cfg/yolov3/yolov3-UAV.cfg",
    "chars": 8277,
    "preview": "\n[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=16\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0."
  },
  {
    "path": "cfg/yolov3/yolov3-asff.cfg",
    "chars": 9310,
    "preview": "# Generated by Glenn Jocher (glenn.jocher@ultralytics.com) for https://github.com/ultralytics/yolov3\n# def kmean_anchors"
  },
  {
    "path": "cfg/yolov3/yolov3-bdd100k.cfg",
    "chars": 8281,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=16\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov3/yolov3-hand.cfg",
    "chars": 8292,
    "preview": "\n[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=16\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0."
  },
  {
    "path": "cfg/yolov3/yolov3-onDIOR.cfg",
    "chars": 8287,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=16\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov3/yolov3-screw.cfg",
    "chars": 8400,
    "preview": "[net]\n# Testing\n#  batch=1\n#  subdivisions=1\n# Training\nbatch=64\nsubdivisions=16\nwidth=256\nheight=256\nchannels=3\nmomentu"
  },
  {
    "path": "cfg/yolov3/yolov3-ship.cfg",
    "chars": 9386,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch = 16\nsubdivisions = 1\nwidth = 416\nheight = 416\nchannels = 3\nmo"
  },
  {
    "path": "cfg/yolov3/yolov3-spp-matrix.cfg",
    "chars": 13427,
    "preview": "[net]\n# Testing\n# batch=1\n# subdivisions=1\n# Training\nbatch=64\nsubdivisions=16\nwidth=416\nheight=416\nchannels=3\nmomentum="
  },
  {
    "path": "cfg/yolov3/yolov3-spp-pan-scale.cfg",
    "chars": 9600,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=64\nsubdivisions=32\nwidth=544\nheight=544\nchannels=3\nmomentum=0."
  },
  {
    "path": "cfg/yolov3/yolov3-spp.cfg",
    "chars": 8605,
    "preview": "[net]\n# Testing\n# batch=1\n# subdivisions=1\n# Training\nbatch=64\nsubdivisions=16\nwidth=608\nheight=608\nchannels=3\nmomentum="
  },
  {
    "path": "cfg/yolov3/yolov3-spp3.cfg",
    "chars": 8959,
    "preview": "[net]\n# Testing\nbatch=1\nsubdivisions=1\n# Training\n# batch=64\n# subdivisions=16\nwidth=608\nheight=608\nchannels=3\nmomentum="
  },
  {
    "path": "cfg/yolov3/yolov3-visdrone.cfg",
    "chars": 8335,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=16\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov3/yolov3.cfg",
    "chars": 8338,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=16\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov3-ghostnet/yolov3-ghost-coco.cfg",
    "chars": 13258,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=16\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov3-mobilenet/yolov3-mobilenet-UAV.cfg",
    "chars": 7553,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=16\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov3-mobilenet/yolov3-mobilenet-coco.cfg",
    "chars": 7616,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=16\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov3-mobilenet/yolov3-mobilenet-hand.cfg",
    "chars": 7568,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=16\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov3-mobilenet/yolov3-mobilenet-screw.cfg",
    "chars": 7568,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=16\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov3-mobilenet/yolov3-mobilenet-visdrone.cfg",
    "chars": 7613,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=16\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov3-singlechannel/yolov3-singlechannel.cfg",
    "chars": 9386,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch = 16\nsubdivisions = 1\nwidth = 416\nheight = 416\nchannels = 1\nmo"
  },
  {
    "path": "cfg/yolov3tiny/yolov3-tiny-UAV.cfg",
    "chars": 2027,
    "preview": "[net]\n# Testing\nbatch=1\nsubdivisions=1\n# Training\nbatch=16\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0.9\nd"
  },
  {
    "path": "cfg/yolov3tiny/yolov3-tiny-hand.cfg",
    "chars": 2029,
    "preview": "[net]\n# Testing\nbatch=1\nsubdivisions=1\n# Training\nbatch=16\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0.9\nd"
  },
  {
    "path": "cfg/yolov3tiny/yolov3-tiny-ship-one.cfg",
    "chars": 1429,
    "preview": "[net]\n# Testing\nbatch=1\nsubdivisions=1\n# Training\n# batch=64\n# subdivisions=2\nwidth=416\nheight=416\nchannels=3\nmomentum=0"
  },
  {
    "path": "cfg/yolov3tiny/yolov3-tiny-ship.cfg",
    "chars": 1917,
    "preview": "[net]\n# Testing\nbatch=1\nsubdivisions=1\n# Training\n# batch=64\n# subdivisions=2\nwidth=416\nheight=416\nchannels=3\nmomentum=0"
  },
  {
    "path": "cfg/yolov3tiny/yolov3-tiny.cfg",
    "chars": 1915,
    "preview": "[net]\n# Testing\nbatch=1\nsubdivisions=1\n# Training\n# batch=64\n# subdivisions=2\nwidth=416\nheight=416\nchannels=3\nmomentum=0"
  },
  {
    "path": "cfg/yolov3tiny/yolov3-tiny3.cfg",
    "chars": 2457,
    "preview": "[net]\n# Testing\n# batch=1\n# subdivisions=1\n# Training\nbatch=64\nsubdivisions=16\nwidth=608\nheight=608\nchannels=3\nmomentum="
  },
  {
    "path": "cfg/yolov3tiny/yolov3-tiny_bdd100k.cfg",
    "chars": 1997,
    "preview": "[net]\n# Testing\nbatch=1\nsubdivisions=1\n# Training\n# batch=64\n# subdivisions=2\nwidth=416\nheight=416\nchannels=3\nmomentum=0"
  },
  {
    "path": "cfg/yolov3tiny/yolov3-tiny_onDIOR.cfg",
    "chars": 2011,
    "preview": "[net]\n# Testing\nbatch=1\nsubdivisions=1\n# Training\n# batch=64\n# subdivisions=2\nwidth=416\nheight=416\nchannels=3\nmomentum=0"
  },
  {
    "path": "cfg/yolov3tiny/yolov3-tiny_visdrone.cfg",
    "chars": 1879,
    "preview": "[net]\n# Testing\nbatch=1\nsubdivisions=1\n# Training\n# batch=64\n# subdivisions=2\nwidth=416\nheight=416\nchannels=3\nmomentum=0"
  },
  {
    "path": "cfg/yolov3tiny-efficientnetB0/yolov3tiny-efficientnetB0.cfg",
    "chars": 12353,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=64\nsubdivisions=8\nwidth=416\nheight=416\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov3tiny-mobilenet-small/yolov3tiny-mobilenet-small-UAV.cfg",
    "chars": 5186,
    "preview": "[net]\n# Testing\nbatch = 1\nsubdivisions = 1\n# Training\n# batch=64\n# subdivisions=2\nwidth = 416\nheight = 416\nchannels = 3\n"
  },
  {
    "path": "cfg/yolov3tiny-mobilenet-small/yolov3tiny-mobilenet-small-coco.cfg",
    "chars": 5212,
    "preview": "[net]\n# Testing\nbatch = 1\nsubdivisions = 1\n# Training\n# batch=64\n# subdivisions=2\nwidth = 416\nheight = 416\nchannels = 3\n"
  },
  {
    "path": "cfg/yolov3tiny-mobilenet-small/yolov3tiny-mobilenet-small-screw.cfg",
    "chars": 5190,
    "preview": "[net]\n# Testing\nbatch = 1\nsubdivisions = 1\n# Training\n# batch=64\n# subdivisions=2\nwidth = 416\nheight = 416\nchannels = 3\n"
  },
  {
    "path": "cfg/yolov3tiny-mobilenet-small/yolov3tiny-mobilenet-small-visdrone.cfg",
    "chars": 5176,
    "preview": "[net]\n# Testing\nbatch = 1\nsubdivisions = 1\n# Training\n# batch=64\n# subdivisions=2\nwidth = 416\nheight = 416\nchannels = 3\n"
  },
  {
    "path": "cfg/yolov4/yolov4-hand.cfg",
    "chars": 12154,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=64\nsubdivisions=8\nwidth=608\nheight=608\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov4/yolov4-relu.cfg",
    "chars": 12279,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=64\nsubdivisions=8\nwidth=608\nheight=608\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov4/yolov4-visdrone.cfg",
    "chars": 12205,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=64\nsubdivisions=8\nwidth=608\nheight=608\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov4/yolov4.cfg",
    "chars": 12209,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=64\nsubdivisions=8\nwidth=608\nheight=608\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "cfg/yolov4tiny/yolov4-tiny.cfg",
    "chars": 3026,
    "preview": "[net]\n# Testing\n#batch=1\n#subdivisions=1\n# Training\nbatch=64\nsubdivisions=1\nwidth=416\nheight=416\nchannels=3\nmomentum=0.9"
  },
  {
    "path": "convert.py",
    "chars": 1517,
    "preview": "# Author:LiPu\nimport argparse\nfrom sys import platform\n\nfrom models import *\nfrom utils.datasets import *\nfrom utils.uti"
  },
  {
    "path": "convert_FPGA.py",
    "chars": 10026,
    "preview": "import argparse\nimport struct\n\nfrom models import *  # set ONNX_EXPORT in models.py\n\nfrom utils.utils import *\n\n\ndef con"
  },
  {
    "path": "convert_FPGA_2.py",
    "chars": 9934,
    "preview": "import argparse\nimport struct\n\nfrom models import *  # set ONNX_EXPORT in models.py\n\nfrom utils.utils import *\n\n\ndef con"
  },
  {
    "path": "data/UAV_Samples_label.data",
    "chars": 123,
    "preview": "classes= 1\ntrain=data/UAV_Samples_label/train.txt\nvalid=data/UAV_Samples_label/test.txt\nnames=data/UAV_Samples_label.nam"
  },
  {
    "path": "data/UAV_Samples_label.names",
    "chars": 4,
    "preview": "UAV\n"
  },
  {
    "path": "data/bdd100k.data",
    "chars": 94,
    "preview": "classes= 10\ntrain=data/bdd100k/train.txt\nvalid=data/bdd100k/test.txt\nnames=data/bdd100k.names\n"
  },
  {
    "path": "data/bdd100k.names",
    "chars": 71,
    "preview": "car\nbus\nperson\nbike\ntruck\nmotor\ntrain\nrider\ntraffic sign\ntraffic light\n"
  },
  {
    "path": "data/coco.names",
    "chars": 621,
    "preview": "person\nbicycle\ncar\nmotorcycle\nairplane\nbus\ntrain\ntruck\nboat\ntraffic light\nfire hydrant\nstop sign\nparking meter\nbench\nbir"
  },
  {
    "path": "data/coco2014.data",
    "chars": 99,
    "preview": "classes=80\ntrain=data/coco2014/train2014.txt\nvalid=data/coco2014/val2014.txt\nnames=data/coco.names\n"
  },
  {
    "path": "data/coco2017.data",
    "chars": 99,
    "preview": "classes=80\ntrain=data/coco2017/train2017.txt\nvalid=data/coco2017/val2017.txt\nnames=data/coco.names\n"
  },
  {
    "path": "data/dior.data",
    "chars": 95,
    "preview": "classes= 20\ntrain=data/DIOR-full/train.txt\nvalid=data/DIOR-full/test.txt\nnames=data/dior.names\n"
  },
  {
    "path": "data/dior.names",
    "chars": 224,
    "preview": "airplane\nairport\nbaseballfield\nbasketballcourt\nbridge\nchimney\ndam\nExpressway-Service-area\nExpressway-toll-station\ngolffi"
  },
  {
    "path": "data/get_coco2014.sh",
    "chars": 824,
    "preview": "#!/bin/bash\n# Zip coco folder\n# zip -r coco.zip coco\n# tar -czvf coco.tar.gz coco\n\n# Download labels from Google Drive, "
  },
  {
    "path": "data/get_coco2017.sh",
    "chars": 824,
    "preview": "#!/bin/bash\n# Zip coco folder\n# zip -r coco.zip coco\n# tar -czvf coco.tar.gz coco\n\n# Download labels from Google Drive, "
  },
  {
    "path": "data/oxfordhand.data",
    "chars": 91,
    "preview": "classes= 1\ntrain=data/hand/train.txt\nvalid=data/hand/valid.txt\nnames=data/oxfordhand.names\n"
  },
  {
    "path": "data/oxfordhand.names",
    "chars": 5,
    "preview": "hand\n"
  },
  {
    "path": "data/screw.data",
    "chars": 113,
    "preview": "classes= 2\ntrain  = data/screw/train.txt\nvalid  = data/screw/valid.txt\nnames = data/screw.names\nbackup = backup\n\n"
  },
  {
    "path": "data/screw.names",
    "chars": 13,
    "preview": "noscrew\nscrew"
  },
  {
    "path": "data/trainset.data",
    "chars": 95,
    "preview": "classes=5\ntrain=data/trainset/train.txt\nvalid=data/trainset/test.txt\nnames=data/trainset.names\n"
  },
  {
    "path": "data/trainset.names",
    "chars": 38,
    "preview": "Freedom\nBurke\nNimitz\nWasp\nTiconderoga\n"
  },
  {
    "path": "data/visdrone.data",
    "chars": 97,
    "preview": "classes= 10\ntrain=data/visdrone/train.txt\nvalid=data/visdrone/test.txt\nnames=data/visdrone.names\n"
  },
  {
    "path": "data/visdrone.names",
    "chars": 75,
    "preview": "pedestrian\npeople\nbicycle\ncar\nvan\ntruck\ntricycle\nawning-tricycle\nbus\nmotor\n"
  },
  {
    "path": "detect.py",
    "chars": 10722,
    "preview": "import argparse\nfrom utils import output_upsample\n\nfrom models import *\nfrom utils.datasets import *\nfrom utils.utils im"
  },
  {
    "path": "info.py",
    "chars": 560,
    "preview": "# Author:LiPu\nimport argparse\nfrom models import *\nfrom torchsummary import summary\n\nparser = argparse.ArgumentParser()\n"
  },
  {
    "path": "layer_channel_prune.py",
    "chars": 12996,
    "preview": "from models import *\nfrom utils.utils import *\nimport numpy as np\nfrom copy import deepcopy\nfrom test import test\nfrom t"
  },
  {
    "path": "layer_channel_regular_prune.py",
    "chars": 15990,
    "preview": "from models import *\nfrom utils.utils import *\nimport numpy as np\nfrom copy import deepcopy\nfrom test import test\nfrom t"
  },
  {
    "path": "layer_prune.py",
    "chars": 8676,
    "preview": "from models import *\nfrom utils.utils import *\nimport torch\nimport numpy as np\nfrom copy import deepcopy\nfrom test impor"
  },
  {
    "path": "models.py",
    "chars": 48007,
    "preview": "from utils.google_utils import *\nfrom utils.parse_config import *\nfrom utils.quantized.quantized_google import *\nfrom ut"
  },
  {
    "path": "normal_prune.py",
    "chars": 8395,
    "preview": "from models import *\nfrom utils.utils import *\nimport torch\nimport numpy as np\nfrom copy import deepcopy\nfrom test impor"
  },
  {
    "path": "regular_prune.py",
    "chars": 10431,
    "preview": "from models import *\nfrom utils.utils import *\nimport torch\nimport numpy as np\nfrom copy import deepcopy\nfrom test impor"
  },
  {
    "path": "requirements.txt",
    "chars": 692,
    "preview": "# pip install -U -r requirements.txt\nCython\nnumpy==1.17\nopencv-python\ntorch>=1.5.1\nmatplotlib\npillow\ntensorboard\ntorchvi"
  },
  {
    "path": "shortcut_prune.py",
    "chars": 9892,
    "preview": "import argparse\n\nfrom models import *\nfrom utils.utils import *\nimport torch\nimport numpy as np\nfrom copy import deepcop"
  },
  {
    "path": "slim_prune.py",
    "chars": 7957,
    "preview": "from models import *\nfrom utils.utils import *\nimport numpy as np\nfrom copy import deepcopy\nfrom test import test\nfrom t"
  },
  {
    "path": "test.py",
    "chars": 13908,
    "preview": "import argparse\nimport json\n\nfrom torch.utils.data import DataLoader\nfrom models import *\nfrom utils.datasets import *\nf"
  },
  {
    "path": "train.py",
    "chars": 35963,
    "preview": "import argparse\n\nimport torch.optim as optim\nimport torch.optim.lr_scheduler as lr_scheduler\nfrom torch.utils.tensorboar"
  },
  {
    "path": "utils/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "utils/adabound.py",
    "chars": 11353,
    "preview": "import math\n\nimport torch\nfrom torch.optim.optimizer import Optimizer\n\n\nclass AdaBound(Optimizer):\n    \"\"\"Implements Ada"
  },
  {
    "path": "utils/datasets.py",
    "chars": 44242,
    "preview": "import glob\nimport math\nimport os\nimport random\nimport shutil\nimport time\nfrom pathlib import Path\nfrom threading import"
  },
  {
    "path": "utils/gcp.sh",
    "chars": 2170,
    "preview": "#!/usr/bin/env bash\n\n# New VM\nrm -rf sample_data yolov3\ngit clone https://github.com/ultralytics/yolov3\n# git clone -b t"
  },
  {
    "path": "utils/google_utils.py",
    "chars": 2666,
    "preview": "# This file contains google utils: https://cloud.google.com/storage/docs/reference/libraries\n# pip install --upgrade goo"
  },
  {
    "path": "utils/layers.py",
    "chars": 6277,
    "preview": "from utils.utils import *\n\n\ndef make_divisible(v, divisor):\n    # Function ensures all layers have a channel number that"
  },
  {
    "path": "utils/output_upsample.py",
    "chars": 3916,
    "preview": "import numpy as np\nimport torch\nimport torch.nn.functional as F\nimport os\nfrom utils.parse_config import *\n\n\n# cfg = './"
  },
  {
    "path": "utils/parse_config.py",
    "chars": 3000,
    "preview": "import os\n\nimport numpy as np\n\n\ndef parse_model_cfg(path):\n    # Parse the yolo *.cfg file and return module definitions"
  },
  {
    "path": "utils/prune_utils.py",
    "chars": 18748,
    "preview": "import torch\nfrom terminaltables import AsciiTable\nfrom copy import deepcopy\nimport numpy as np\nimport torch.nn.function"
  },
  {
    "path": "utils/quantized/__init__.py",
    "chars": 14,
    "preview": "# Author:LiPu\n"
  },
  {
    "path": "utils/quantized/quantized_TPSQ.py",
    "chars": 23696,
    "preview": "# Author:LiPu\nimport numpy as np\nimport os\nimport time\nimport math\nimport torch\nimport torch.nn as nn\nimport torch.nn.fu"
  },
  {
    "path": "utils/quantized/quantized_dorefa.py",
    "chars": 17962,
    "preview": "# Author:LiPu\nimport time\nimport numpy as np\nimport os\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as"
  },
  {
    "path": "utils/quantized/quantized_google.py",
    "chars": 73442,
    "preview": "import copy\nimport math\nimport time\nimport numpy as np\nimport os\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.fun"
  },
  {
    "path": "utils/quantized/quantized_lowbit.py",
    "chars": 3948,
    "preview": "# Author:LiPu\nimport math\nimport torch\nimport torch.nn as nn\nfrom torch.autograd import Function\nimport torch.nn.functio"
  },
  {
    "path": "utils/quantized/quantized_ptq.py",
    "chars": 40920,
    "preview": "# Author:LiPu\nimport math\nimport time\nimport numpy as np\nimport os\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.f"
  },
  {
    "path": "utils/quantized/quantized_ptq_cos.py",
    "chars": 74927,
    "preview": "# Author:LiPu\nimport math\nimport numpy as np\nimport os\nimport copy\nimport torch\nimport torch.nn as nn\nimport torch.nn.fu"
  },
  {
    "path": "utils/torch_utils.py",
    "chars": 8241,
    "preview": "from copy import deepcopy\n\nimport torch.backends.cudnn as cudnn\nfrom utils.quantized.quantized_google import *\n\n\ndef ini"
  },
  {
    "path": "utils/utils.py",
    "chars": 57832,
    "preview": "import glob\nimport math\nimport os\nimport random\nimport shutil\nimport subprocess\nfrom pathlib import Path\nfrom sys import"
  },
  {
    "path": "weights/pretrain_weights/download_yolov3_weights.sh",
    "chars": 896,
    "preview": "#!/bin/bash\n\n# make '/weights' directory if it does not exist and cd into it\n# mkdir -p weights && cd weights\n\n# copy da"
  }
]

About this extraction

This page contains the full source code of the SpursLipu/YOLOv3v4-ModelCompression-MultidatasetTraining-Multibackbone GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 103 files (972.9 KB), approximately 288.6k tokens, and a symbol index with 471 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!