(names, path, name2idx=None, key='global_descriptor')
| 34 | |
| 35 | |
| 36 | def get_descriptors(names, path, name2idx=None, key='global_descriptor'): |
| 37 | if name2idx is None: |
| 38 | with h5py.File(str(path), 'r', libver='latest') as fd: |
| 39 | desc = [fd[n][key].__array__() for n in names] |
| 40 | else: |
| 41 | desc = [] |
| 42 | for n in names: |
| 43 | with h5py.File(str(path[name2idx[n]]), 'r', libver='latest') as fd: |
| 44 | desc.append(fd[n][key].__array__()) |
| 45 | return torch.from_numpy(np.stack(desc, 0)).float() |
| 46 | |
| 47 | |
| 48 | def pairs_from_score_matrix(scores: torch.Tensor, |