Exemple #1
0
# 使用restnet网络

# check if weight path was passed via command line
if cfg.input_weight_path:  # 这里已经被赋值为cfg里的值
    cfg.base_net_weights = cfg.input_weight_path
else:
    # set the path to weights based on backend and model
    cfg.base_net_weights = nn.get_weight_path()
# 设定restore路径

all_imgs, classes_count, class_mapping, bird_class_count, bird_class_mapping = get_data(
    cfg.train_path)  # get_data函数在pascalvocparser.py里变

data_lei = march.get_voc_label(all_imgs,
                               classes_count,
                               class_mapping,
                               bird_class_count,
                               bird_class_mapping,
                               trainable=True)

if 'bg' not in classes_count:
    classes_count['bg'] = 0
    class_mapping['bg'] = len(class_mapping)

cfg.class_mapping = class_mapping

inv_map = {v: k for k, v in class_mapping.items()}

print('Training images per class:')
pprint.pprint(classes_count)
print('Num classes (including bg) = {}'.format(len(classes_count)))
print('Training bird per class:')
Exemple #2
0
else:
    print('Not a valid model')
    raise ValueError

if cfg.input_weight_path:  # 这里已经被赋值为cfg里的值
    cfg.base_net_weights = cfg.input_weight_path
else:
    print('does not init')
    #raise ValueError

all_imgs, classes_count, bird_class_count = get_data(cfg.train_path,
                                                     part_class_mapping)
data_lei = march.get_voc_label(all_imgs,
                               classes_count,
                               part_class_mapping,
                               bird_class_count,
                               bird_class_mapping,
                               config=cfg,
                               trainable=False)
#pprint.pprint(classes_count)
#pprint.pprint(part_class_mapping)
# 这里的类在match里边定义
if 'bg' not in classes_count:
    classes_count['bg'] = 0
    part_class_mapping['bg'] = len(part_class_mapping)

cfg.class_mapping = part_class_mapping

print('Training images per class:')
pprint.pprint(classes_count)
pprint.pprint(part_class_mapping)