'use_smooth_loss': args.use_smooth_loss, 'use_seg_loss': args.use_seg_loss, 'sim_loss_type': args.sim_loss_type, 'gamma': args.gamma, 'lamda': args.lamda, 'training_classes': args.training_classes, 'val_classes': args.val_classes, 'test_classes': args.test_classes, 'shots': args.shots, } assert set(args.training_classes + args.test_classes + args.val_classes) == set(range(1, 7)) assert len(args.training_classes) + len(args.test_classes) + len( args.val_classes) == 6 set_cfg(new_cfg) logging.info("Config:") logging.info(cfg) # Train the network reg_model = train_network() # Evaluate on test data evaluate_network(reg_model) # Download the reports and model download_results()
elif hiden_layer_idx == 2: hiden_com = [[x, y] for x in range(1, 16) for y in range(1, 16)] elif hiden_layer_idx == 3: hiden_com = [[x, y, z] for x in [2, 10] for y in [2, 10] for z in [2, 10]] for hi in hiden_com: BP_size = [n_dim * cfg.RECEPTIVE, 1] BP_size.insert(1, hi) BP_sizes = [] for x in BP_size: if isinstance(x, int): BP_sizes.append(x) else: BP_sizes.extend(x) for learn in [16]: for epoch in [200, 500, 1000, 2000, 3000, 4000]: a = len(BP_sizes) cfg.set_cfg(lay_num=len(BP_sizes) - 2, node_num=BP_sizes[1:-1], epoch=epoch) print('hello,this is hiden_layer_num={0},hiden={1},out={2}'.format(hiden_layer_idx, hi, BP_sizes)) net = snn.StockNetwork(BP_sizes) net.SGD(training_data=training_data, epochs=epoch, mini_batch_size=12, learn_rate=learn*0.01, test_data=test_data) # test_data None print('[Processing]: The config information is:.....')
# Warning: hacky make_row = lambda vals: (' %5s |' * len(vals)) % tuple(vals) make_sep = lambda n: ('-------+' * n) print() print(make_row([''] + [('.%d ' % x if isinstance(x, int) else x + ' ') for x in all_maps['box'].keys()])) print(make_sep(len(all_maps['box']) + 1)) for iou_type in ('box', 'mask'): print(make_row([iou_type] + ['%.2f' % x for x in all_maps[iou_type].values()])) print(make_sep(len(all_maps['box']) + 1)) print() if __name__ == '__main__': parse_args() if args.config is not None: set_cfg(args.config) if args.trained_model == 'interrupt': args.trained_model = SavePath.get_interrupt('weights/') elif args.trained_model == 'latest': args.trained_model = SavePath.get_latest('weights/', cfg.name) if args.config is None: model_path = SavePath.from_str(args.trained_model) # TODO: Bad practice? Probably want to do a name lookup instead. args.config = model_path.model_name + '_config' print('Config not specified. Parsed %s from the file name.\n' % args.config) set_cfg(args.config) if args.detect: cfg.eval_mask_branch = False
return self.detect(pred_outs) # Some testing code if __name__ == '__main__': from utils.functions import init_console init_console() # Use the first argument to set the config if you want import sys if len(sys.argv) > 1: from config import set_cfg set_cfg(sys.argv[1]) net = Yolact() net.train() net.init_weights(backbone_path='weights/' + cfg.backbone.path) # GPU net = net.cuda() cudnn.benchmark = True torch.set_default_tensor_type('torch.cuda.FloatTensor') x = torch.zeros((1, 3, cfg.max_size, cfg.max_size)) y = net(x) for p in net.prediction_layers: print(p.last_conv_size)