-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
23 lines (19 loc) · 782 Bytes
/
Copy pathsetup.py
File metadata and controls
23 lines (19 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
import cv2
import pandas as pd
def store_cub_image_sizes(root):
paths = pd.read_csv(
os.path.join(root, 'CUB_200_2011', 'images.txt'),
sep=' ', names=['id', 'path'])
sizes = pd.DataFrame(columns=['id', 'width', 'height'])
for i in range(len(paths)):
path = paths.iloc[i].path
image_path = os.path.join(root, 'CUB_200_2011/images', path)
image = cv2.imread(image_path)
sizes.loc[i] = [paths.iloc[i].id, image.shape[1], image.shape[0]]
save_path = os.path.join(root, 'CUB_200_2011', 'image_sizes.txt')
sizes.to_csv(path_or_buf=save_path, sep=' ', index=False, header=False)
if __name__ == '__main__':
root = 'data'
print('Storing image sizes of cub200 dataset')
store_cub_image_sizes(root)