Skip to content

Commit

Permalink
add veriwild
Browse files Browse the repository at this point in the history
  • Loading branch information
mengdechao committed Aug 9, 2020
1 parent d580632 commit 697d4cd
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
examples/EDA/*
examples/outputs/*
*.pth
__pycache__
*.egg-info
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion examples/parsing/generate_masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
49 changes: 49 additions & 0 deletions examples/preprocess_data/preprocess_veriwild.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 697d4cd

Please sign in to comment.