cd80a074396caa42b81068115c9b066f4ce08414,train_img_model_xent.py,,test,#Any#Any#Any#Any#Any#,204

Before Change


    print("Extracted features for query set, obtained {}-by-{} matrix".format(qf.size(0), qf.size(1)))

    gf, g_pids, g_camids = [], [], []
    for batch_idx, (imgs, pids, camids) in enumerate(galleryloader):
        if use_gpu:
            imgs = imgs.cuda()
        imgs = Variable(imgs, volatile=True)
        features = model(imgs)
        features = features.data.cpu()
        gf.append(features)
        g_pids.extend(pids)
        g_camids.extend(camids)
    gf = torch.cat(gf, 0)
    g_pids = np.asarray(g_pids)
    g_camids = np.asarray(g_camids)

After Change


def test(model, queryloader, galleryloader, use_gpu, ranks=[1, 5, 10, 20]):
    model.eval()

    with torch.no_grad():
        qf, q_pids, q_camids = [], [], []
        for batch_idx, (imgs, pids, camids) in enumerate(queryloader):
            if use_gpu: imgs = imgs.cuda()
            features = model(imgs)
            features = features.data.cpu()
            qf.append(features)
            q_pids.extend(pids)
            q_camids.extend(camids)
        qf = torch.cat(qf, 0)
        q_pids = np.asarray(q_pids)
        q_camids = np.asarray(q_camids)

        print("Extracted features for query set, obtained {}-by-{} matrix".format(qf.size(0), qf.size(1)))

        gf, g_pids, g_camids = [], [], []
        for batch_idx, (imgs, pids, camids) in enumerate(galleryloader):
            if use_gpu: imgs = imgs.cuda()
            features = model(imgs)
            features = features.data.cpu()
            gf.append(features)
            g_pids.extend(pids)
            g_camids.extend(camids)
        gf = torch.cat(gf, 0)
        g_pids = np.asarray(g_pids)
        g_camids = np.asarray(g_camids)

        print("Extracted features for gallery set, obtained {}-by-{} matrix".format(gf.size(0), gf.size(1)))
    
    print("Computing distance matrix")

    m, n = qf.size(0), gf.size(0)
    distmat = torch.pow(qf, 2).sum(dim=1, keepdim=True).expand(m, n) + \
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: KaiyangZhou/deep-person-reid
Commit Name: cd80a074396caa42b81068115c9b066f4ce08414
Time: 2018-04-26
Author: k.zhou@qmul.ac.uk
File Name: train_img_model_xent.py
Class Name:
Method Name: test


Project Name: KaiyangZhou/deep-person-reid
Commit Name: cd80a074396caa42b81068115c9b066f4ce08414
Time: 2018-04-26
Author: k.zhou@qmul.ac.uk
File Name: train_vid_model_xent_htri.py
Class Name:
Method Name: test


Project Name: KaiyangZhou/deep-person-reid
Commit Name: cd80a074396caa42b81068115c9b066f4ce08414
Time: 2018-04-26
Author: k.zhou@qmul.ac.uk
File Name: train_vid_model_xent.py
Class Name:
Method Name: test