diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6b56e65 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +examples/EDA/* +examples/outputs/* +*.pth +__pycache__ +*.egg-info \ No newline at end of file diff --git a/README.md b/README.md index bd496f7..d64332c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This is the official code of article "Parsing-based viewaware embedding network ## Install Clone this repository. Then excute the following commands ``` -cd vehcile_reid.pytorch +cd PVEN pip install -r requirements.txt python setup.py install ``` diff --git a/examples/parsing/generate_masks.py b/examples/parsing/generate_masks.py index 1b50a21..539988e 100644 --- a/examples/parsing/generate_masks.py +++ b/examples/parsing/generate_masks.py @@ -53,7 +53,7 @@ def predict(model, test_dataset, test_dataset_vis, output_path): metas = pickle.load(f) output_path = Path(args.output_path).absolute() - for phase in ['train', 'query', 'gallery']: + for phase in metas.keys(): sub_path = output_path / phase mkdir_p(str(sub_path)) dataset = VehicleReIDParsingDataset(metas[phase], augmentation=get_validation_augmentation(), diff --git a/examples/preprocess_data/preprocess_veriwild.py b/examples/preprocess_data/preprocess_veriwild.py new file mode 100644 index 0000000..550cf5b --- /dev/null +++ b/examples/preprocess_data/preprocess_veriwild.py @@ -0,0 +1,49 @@ +import pandas as pd +import os +import pickle as pkl +import click + + +@click.command() +@click.option('--input-path', default='/home/aa/mengdechao/datasets/veriwild') +@click.option('--output-path', default='../outputs/veriwild.pkl') +def veriwild(input_path, output_path): + PATH = input_path + + images = {} + + images['train'] = open(PATH + '/train_test_split/train_list.txt').read().strip().split('\n') + images['query_3000'] = open(PATH + '/train_test_split/test_3000_query.txt').read().strip().split('\n') + images['gallery_3000'] = open(PATH + '/train_test_split/test_3000.txt').read().strip().split('\n') + images['query_5000'] = open(PATH + '/train_test_split/test_5000_query.txt').read().strip().split('\n') + images['gallery_5000'] = open(PATH + '/train_test_split/test_5000.txt').read().strip().split('\n') + images['query_10000'] = open(PATH + '/train_test_split/test_10000_query.txt').read().strip().split('\n') + images['gallery_10000']= open(PATH + '/train_test_split/test_10000.txt').read().strip().split('\n') + + wild_df = pd.read_csv(f'{PATH}/train_test_split/vehicle_info.txt', sep=';', index_col='id/image') + wild_dict = wild_df.to_dict() + camid_dict = wild_dict['Camera ID'] + + outputs = {} + for key, lists in images.items(): + output = [] + for img_name in lists: + item = { + "image_path": f"{PATH}/images/{img_name}.jpg", + "name": img_name, + "id": img_name.split('/')[0], + # "cam": wild_df.loc[img_name]['Camera ID'] + "cam": camid_dict[img_name] + } + output.append(item) + outputs[key] = output + + base_path = os.path.split(output_path)[0] + if base_path != '' and not os.path.exists(base_path): + os.makedirs(base_path, exist_ok=True) + with open(output_path, 'wb') as f: + pkl.dump(outputs, f) + + +if __name__ == "__main__": + veriwild() \ No newline at end of file