(features_path, output_path, show_num_identities_for_each_domain=100)
| 641 | |
| 642 | |
| 643 | def visualize2(features_path, output_path, show_num_identities_for_each_domain=100): |
| 644 | from collections import defaultdict |
| 645 | datasets = defaultdict(dict) |
| 646 | if not osp.exists(features_path): |
| 647 | assert False, f'features_path ({features_path}) is not existing!' |
| 648 | query_dict_list, gallery_dict_list = [], [] |
| 649 | for _file in sorted(os.listdir(features_path)): |
| 650 | print(_file) |
| 651 | if 'cids' in _file: |
| 652 | continue |
| 653 | features = np.load(osp.join(features_path, _file)) |
| 654 | dataset_name = re.findall(p1, _file)[0] |
| 655 | if 'pids' in _file: |
| 656 | if 'pids' in datasets[dataset_name].keys(): |
| 657 | datasets[dataset_name]['pids'] = np.concatenate( |
| 658 | (datasets[dataset_name]['pids'], features), axis=0) |
| 659 | # print(f'{dataset_name} ==> add pids: {features.shape}') |
| 660 | else: |
| 661 | datasets[dataset_name].update({'pids': features}) |
| 662 | # print(f'{dataset_name} ==> initial pids: {features.shape}') |
| 663 | |
| 664 | elif 'features' in _file: |
| 665 | if 'features' in datasets[dataset_name].keys(): |
| 666 | datasets[dataset_name]['features'] = np.concatenate( |
| 667 | (datasets[dataset_name]['features'], features), axis=0) |
| 668 | # print(f'{dataset_name} ==> add features: {features.shape}') |
| 669 | else: |
| 670 | datasets[dataset_name].update({'features': features}) |
| 671 | # print(f'{dataset_name} ==> initial features: {features.shape}') |
| 672 | else: |
| 673 | assert False, f'the name of _file is {_file}, which is not compatible' |
| 674 | |
| 675 | print(list(datasets.keys())) |
| 676 | for k, v in datasets.items(): |
| 677 | # print(k) |
| 678 | # print(np.max(v['pids'])) |
| 679 | # print(np.min(v['pids'])) |
| 680 | v['pids'] = relabel_numpy(v['pids']) |
| 681 | # print(np.max(v['pids'])) |
| 682 | # print(np.min(v['pids'])) |
| 683 | |
| 684 | for k, v in datasets.items(): |
| 685 | selected_ids = np.random.permutation(np.max(v['pids']))[ |
| 686 | :show_num_identities_for_each_domain] |
| 687 | |
| 688 | index = np.arange(v['pids'].shape[0]) |
| 689 | # for ii, pid in enumerate(v['pids']): |
| 690 | # if pid in selected_ids: |
| 691 | # if 'selected_features' and 'selected_pids' in v.keys(): |
| 692 | # v['selected_features'] = np.concatenate((v['selected_features'], v['features'][ii]), axis=0) |
| 693 | # assert v['pids'][ii] == pid, 'conflict' |
| 694 | # v['selected_pids'] = np.concatenate((v['selected_pids'], pid), axis=0) |
| 695 | # else: |
| 696 | # v.update({'selected_features': v['features'][ii]}) |
| 697 | # assert v['pids'][ii] == pid, 'conflict' |
| 698 | # v.update({'selected_pids': pid}) |
| 699 | delete_index = [] |
| 700 | for ii, pid in enumerate(v['pids']): |
nothing calls this directly
no test coverage detected