1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| # 咖喱的代码
import os
import glob
import os.path as osp
dataset_dir = os.getcwd()
bulbasaur_dir = osp.join(dataset_dir, 'pokeman/bulbasaur')
charmander_dir = osp.join(dataset_dir, 'pokeman/charmander')
mewtwo_dir = osp.join(dataset_dir, 'pokeman/mewtwo')
pikachu_dir = osp.join(dataset_dir, 'pokeman/pikachu')
squirtle_dir = osp.join(dataset_dir, 'pokeman/squirtle')
def process(dir_path, save_path):
img_paths = glob.glob(osp.join(dir_path, '*.jpg'))
f= open(save_path, 'w')
for img_path in img_paths:
f.write(img_path)
f.write('\n')
f.close()
dataset_dir = os.getcwd()
bulbasaur_dir = osp.join(dataset_dir, 'pokeman/bulbasaur')
charmander_dir = osp.join(dataset_dir, 'pokeman/charmander')
mewtwo_dir = osp.join(dataset_dir, 'pokeman/mewtwo')
pikachu_dir = osp.join(dataset_dir, 'pokeman/pikachu')
squirtle_dir = osp.join(dataset_dir, 'pokeman/squirtle')
save_dir = osp.join(dataset_dir, 'imgpath.txt')
process(test_dir, save_dir)
|