| 96 | |
| 97 | |
| 98 | def extract_gall_feat(gall_loader, net): |
| 99 | net.eval() |
| 100 | print('Extracting Gallery Feature...') |
| 101 | start = time.time() |
| 102 | ptr = 0 |
| 103 | gall_feat_fc = np.zeros((ngall, pool_dim)) |
| 104 | with torch.no_grad(): |
| 105 | for batch_idx, (input, label) in enumerate(gall_loader): |
| 106 | batch_num = input.size(0) |
| 107 | input = input.cuda() |
| 108 | _, feat_fc = net(input, input, test_mode[0]) |
| 109 | gall_feat_fc[ptr:ptr + batch_num, :] = feat_fc.detach().cpu().numpy() |
| 110 | ptr = ptr + batch_num |
| 111 | print('Extracting Time:\t {:.3f}'.format(time.time() - start)) |
| 112 | return gall_feat_fc |
| 113 | |
| 114 | |
| 115 | def extract_query_feat(query_loader, net): |