if args.net == 'vgg16': fasterRCNN = vgg16(imdb.classes, pretrained=True, class_agnostic=args.class_agnostic, lc=args.lc) elif args.net == 'res101': fasterRCNN = resnet(imdb.classes, 101, pretrained=True, class_agnostic=args.class_agnostic, lc=args.lc) elif args.net == 'prefood': fasterRCNN = PreResNet50Attention(imdb.classes, pretrained=True, class_agnostic=args.class_agnostic, lc=args.lc, gc=False) else: print("network is not defined") pdb.set_trace() fasterRCNN.create_architecture() lr = cfg.TRAIN.LEARNING_RATE lr = args.lr # tr_momentum = cfg.TRAIN.MOMENTUM # tr_momentum = args.momentum params = []
def init_network(args): # initilize the network here. if args.net == 'vgg16': fasterRCNN = vgg16(imdb.classes, pretrained=args.pretrained, class_agnostic=args.class_agnostic) elif args.net == 'res101': fasterRCNN = resnet(imdb.classes, 101, pretrained=args.pretrained, class_agnostic=args.class_agnostic) elif args.net == 'res50': fasterRCNN = resnet(imdb.classes, 50, pretrained=args.pretrained, class_agnostic=args.class_agnostic) elif args.net == 'res152': fasterRCNN = resnet(imdb.classes, 152, pretrained=args.pretrained, class_agnostic=args.class_agnostic) elif args.net == 'foodres50': fasterRCNN = PreResNet50(imdb.classes, pretrained=args.pretrained, class_agnostic=args.class_agnostic, weight_file=args.weight_file, fixed_layer=args.fixed_layer) elif args.net == 'foodres50attention': fasterRCNN = PreResNet50Attention(imdb.classes, pretrained=args.pretrained, class_agnostic=args.class_agnostic, weight_file=args.weight_file, fixed_layer=args.fixed_layer) elif args.net == 'foodres502fc': fasterRCNN = PreResNet502Fc(imdb.classes, pretrained=args.pretrained, class_agnostic=args.class_agnostic, weight_file=args.weight_file, fixed_layer=args.fixed_layer) elif args.net == 'foodres50meta': fasterRCNN = PreResNet50Meta([0 for _ in range(170)], pretrained=args.pretrained, class_agnostic=args.class_agnostic, weight_file=args.weight_file, fixed_layer=args.fixed_layer) elif args.net == 'foodres50_hierarchy': main_classes = get_main_cls(imdb.classes) fasterRCNN = PreResNet50Hierarchy(main_classes, imdb.classes, pretrained=args.pretrained, class_agnostic=args.class_agnostic, weight_file=args.weight_file, fixed_layer=args.fixed_layer) elif 'foodres50_hierarchy_casecade' in args.net: nets_param = args.net.split('_') if len(nets_param) == 3: casecade_type = 'add_score' alpha = 0.5 elif len(nets_param) == 5: casecade_type = "".join(nets_param[3:5]) alpha = 0.5 elif len(nets_param) == 6: casecade_type = "".join(nets_param[3:5]) alpha = float(nets_param[5]) main_classes = get_main_cls(imdb.classes) fasterRCNN = PreResNet50HierarchyCasecade( main_classes, imdb.classes, pretrained=args.pretrained, class_agnostic=args.class_agnostic, weight_file=args.weight_file, fixed_layer=args.fixed_layer, casecade_type=casecade_type, alpha=alpha) else: print("network is not defined") pdb.set_trace() return fasterRCNN
pretrained=True, class_agnostic=args.class_agnostic, lc=args.lc, gc=args.gc) elif args.net == 'res50': fasterRCNN = resnet(imdb.classes, 50, pretrained=True, class_agnostic=args.class_agnostic, context=args.context) elif args.net == 'prefood': fasterRCNN = PreResNet50Attention(imdb.classes, pretrained=True, class_agnostic=args.class_agnostic, fixed_layer=args.fixed_layer, lc=args.lc, gc=args.gc) else: print("network is not defined") pdb.set_trace() fasterRCNN.create_architecture() lr = cfg.TRAIN.LEARNING_RATE lr = args.lr # tr_momentum = cfg.TRAIN.MOMENTUM # tr_momentum = args.momentum params = []