-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathincrease_data.py
78 lines (41 loc) · 1.64 KB
/
increase_data.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import os
from augmentation.augment_data10 import augment_data10
from augmentation.augment_data6 import augment_data6
from augmentation.augment_data4 import augment_data4
import argparse
def new_dataset_len(path_name):
print("final total images .. " , len(os.listdir(os.path.join(path_name, "image"))))
print("final total masks .. " , len(os.listdir(os.path.join(path_name, "mask"))))
parser = argparse.ArgumentParser()
parser.add_argument('--images_path', type=str, default = './',
help='Path where the images folder is stored')
parser.add_argument('--masks_path', type=str, default = './',
help='Path where the masks folder is stored')
parser.add_argument('--target_folder', type=str, default = './',
help='Target folder where the images folder and the maskes folder are stored')
parser.add_argument('--n', type=int, default = 6,
help='Increase the data n number of times')
args = parser.parse_args()
path_img = args.images_path
path_label = args.masks_path
n = args.n
target = args.target_folder
img = []
for f in sorted(os.listdir(path_img)):
img.append(os.path.join(path_img ,f))
labels = []
for f in sorted(os.listdir(path_label)):
labels.append(os.path.join(path_label,f))
print("initial total masks .. " , len(labels))
print("initial total images .. " , len(img))
if(n == 4 ):
augment_data4(img, labels,target )
new_dataset_len(target)
elif(n == 6):
augment_data6(img, labels, target )
new_dataset_len(target)
elif(n == 10):
augment_data10(img, labels, target )
new_dataset_len(target)
else:
print("invalid ..")