コード例 #1
0
def main():
    model = Baseline(num_classes=702,
                     last_stride=1,
                     model_path=' ',
                     stn='no',
                     model_name='resnet50_ibn_a',
                     pretrain_choice=' ')
    model.load_param('models/resnet50_ibn_a/duke_resnet50_ibn_a_model.pth')
    model.to(device)
    model.eval()

    feats = []
    with torch.no_grad():
        img1 = process_img(
            '/home/zzg/Datasets/DukeReiD/DukeMTMC-reID/query/0033_c1_f0057706.jpg'
        )
        feat1 = model(img1)
        feats.append(feat1)

        img2 = process_img(
            '/home/zzg/Datasets/DukeReiD/DukeMTMC-reID/query/0033_c6_f0045755.jpg'
        )
        feat2 = model(img2)
        feats.append(feat2)

        img3 = process_img(
            '/home/zzg/Datasets/DukeReiD/DukeMTMC-reID/query/0034_c2_f0057453.jpg'
        )
        feat3 = model(img3)
        feats.append(feat3)
    feats = torch.cat(feats, dim=0)
    feats = torch.nn.functional.normalize(feats, dim=1, p=2)
    dist = euclidean_dist_rank(feats, feats)
    print(dist)
コード例 #2
0
def main():
    model = Baseline(num_classes=702,
                     last_stride=1,
                     model_path=' ',
                     stn='no',
                     model_name='resnet50_ibn_a',
                     pretrain_choice=' ')
    model.load_param('models/resnet50_ibn_a/duke_resnet50_ibn_a_model.pth')
    model.to(device)
    model.eval()

    feats = []
    with torch.no_grad():
        img1 = process_img(
            '/nfs4/ajaym/Downloads/Ranked_Person_ReID-master/demo_data/1.jpg')
        feat1 = model(img1)
        feats.append(feat1)

        img2 = process_img(
            '/nfs4/ajaym/Downloads/Ranked_Person_ReID-master/demo_data/2.jpg')
        feat2 = model(img2)
        feats.append(feat2)

        img3 = process_img(
            '/nfs4/ajaym/Downloads/Ranked_Person_ReID-master/demo_data/3.jpg')
        feat3 = model(img3)
        feats.append(feat3)
    feats = torch.cat(feats, dim=0)
    feats = torch.nn.functional.normalize(feats, dim=1, p=2)
    dist = euclidean_dist_rank(feats, feats)
    print(dist)