示例#1
0
args = parser.parse_args()

os.environ['CUDA_VISIBLE_DEVICES'] = args.gpus

label_dims = {'cifar10': 10, 'nuswide_81': 81, 'coco': 80}
Rs = {'cifar10': 54000, 'nuswide_81': 5000, 'coco': 5000}
args.R = Rs[args.dataset]
args.label_dim = label_dims[args.dataset]

args.img_tr = os.path.join(args.data_dir, args.dataset, "train.txt")
args.img_te = os.path.join(args.data_dir, args.dataset, "test.txt")
args.img_db = os.path.join(args.data_dir, args.dataset, "database.txt")

pprint(vars(args))

data_root = os.path.join(args.data_dir, args.dataset)
query_img, database_img = dataset.import_validation(data_root, args.img_te,
                                                    args.img_db)

if not args.evaluate:
    train_img = dataset.import_train(data_root, args.img_tr)
    model_weights = model.train(train_img, database_img, query_img, args)
    args.model_weights = model_weights
else:
    maps = model.validation(database_img, query_img, args)
    for key in maps:
        print(("{}\t{}".format(key, maps[key])))

pprint(vars(args))
示例#2
0
parser.add_argument('--save-dir', default="./models/", type=str)
parser.add_argument('-e', '--evaluate', dest='evaluate', action='store_true')
parser.add_argument('--val-freq', default=1, type=int)

args = parser.parse_args()

os.environ['CUDA_VISIBLE_DEVICES'] = args.gpus

label_dims = {'cifar10': 10, 'nuswide_81': 81, 'coco': 80, 'imagenet': 100}
Rs = {'cifar10': 54000, 'nuswide_81': 5000, 'coco': 5000, 'imagenet': 5000}
args.R = Rs[args.dataset]
args.label_dim = label_dims[args.dataset]
args.img_tr = "/home/caoyue/data/{}/train.txt".format(args.dataset)
args.img_te = "/home/caoyue/data/{}/test.txt".format(args.dataset)
args.img_db = "/home/caoyue/data/{}/database.txt".format(args.dataset)

pprint(vars(args))

query_img, database_img = dataset.import_validation(args.img_te, args.img_db)

if not args.evaluate:
    train_img = dataset.import_train(args.img_tr)
    model_weights = model.train(train_img, database_img, query_img, args)
    args.model_weights = model_weights
else:
    maps = model.validation(database_img, query_img, args)
    for key in maps:
        print(("{}\t{}".format(key, maps[key])))

pprint(vars(args))