-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_npydata.py
34 lines (28 loc) · 983 Bytes
/
make_npydata.py
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 numpy as np
if not os.path.exists('./npydata'):
os.makedirs('./npydata')
'''please set your dataset path'''
cell_root = './data/CoNIC'
a , b = 0, 0
try:
shanghaiAtrain_path = cell_root + '/train/images/'
shanghaiAtest_path = cell_root + '/test/images/'
train_list = []
for filename in os.listdir(shanghaiAtrain_path):
if filename.split('.')[1] == 'jpg':
a += 1
train_list.append(shanghaiAtrain_path + filename)
train_list.sort()
np.save('./npydata/CoNIC_train.npy', train_list)
test_list = []
for filename in os.listdir(shanghaiAtest_path):
if filename.split('.')[1] == 'jpg':
b += 1
test_list.append(shanghaiAtest_path + filename)
test_list.sort()
np.save('./npydata/CoNIC_test.npy', test_list)
print('\n', "train:", a, "test",b)
print("generate image list successfully")
except:
print("The dataset path is wrong. Please check you path.")