-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
78 lines (60 loc) · 2.31 KB
/
main.py
File metadata and controls
78 lines (60 loc) · 2.31 KB
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
"""Module main"""
import os
import sys
import argparse
import dask.array as da
import pandas as pd
def main():
"""
main
:return:
"""
# Clear the current set of images
directories.clear()
# A summary of images metadata & labels, a list of the label fields, and a list of the metadata fields
inventory, fields, labels = preliminaries.exc()
# Prepare
inventory = prepare.exc(data=inventory, fields=fields, labels=labels)
# If preview has a value
if args.sample is not None:
limit = args.sample
else:
limit = inventory.shape[0]
# Directory for augmentations
directories.create()
# Augmentation
outcomes = [generator.exc(filename=image_url.compute(), angle=angle.compute())
for image_url, angle
in da.from_array(inventory[['image_url', 'angle']].to_numpy()[:limit], chunks=(64, 2))]
augmentations = pd.DataFrame(outcomes, columns=['name', 'image', 'angle', 'drawn'])
# Save inventory, split the directory of image files into smaller directories, zip
write.exc(inventory, augmentations)
if __name__ == '__main__':
root = os.getcwd()
sys.path.append(root)
sys.path.append(os.path.join(root, 'src'))
import src.data.generator
import src.data.prepare
import src.data.preliminaries
import src.data.write
import src.io.directories
import src.io.arguments
# Parse the expected input argument
arguments = src.io.arguments.Arguments()
parser = argparse.ArgumentParser()
parser.add_argument('elements',
type=arguments.url,
help='The URL of a YAML of parameters; refer to the README notes. The argument '
'parser returns a blob of elements')
parser.add_argument("--sample", type=arguments.sample,
help="Augment a specified, small, number of images")
args = parser.parse_args()
# Get the data parameters encoded by the input
var = arguments.parameters(elements=args.elements)
# Instances
directories = src.io.directories.Directories(var=var)
preliminaries = src.data.preliminaries.Preliminaries(var=var)
prepare = src.data.prepare.Prepare(var=var)
generator = src.data.generator.Generator(var=var)
write = src.data.write.Write(var=var)
main()