-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFinal_Python.py
61 lines (44 loc) · 1.58 KB
/
Final_Python.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
import os
import sys
from B1_Crawl import Crawl
from B2_ReadLabel import ReadLabel
from B3_Standardization import Standardization
from B4_Plot import Plot
HELP = '''
-mp : for enable multi processing in some cases
-d:folder-name : for new dataset with folder-name ( non-space separated )
-i:30 : for max items of each category
-c:5 : for max categories
'''
def main():
dataset = 'dataset'
enableMultiProcessing = False
maxItems = 0
maxCategories = 0
# collect argv from cmd
if sys.argv and len( sys.argv ) >= 2:
for opt in sys.argv[ 1: ]:
if opt[ :2 ] == '-h':
print( HELP )
return
if opt[ :3 ] == '-mp':
enableMultiProcessing = True
if opt[ :3 ] == '-d:':
dataset = opt[ 3: ]
if opt[ :3 ] == '-i:':
maxItems = opt[ 3: ]
if opt[ :3 ] == '-c:':
maxCategories = opt[ 3: ]
# collect new dataset
if dataset != 'dataset'\
and not os.path.exists( os.path.join( os.getcwd(), dataset ) ):
Crawl( dataset, maxCategories, maxItems )
# loop over each category
for category in os.listdir( os.path.join( os.getcwd(), dataset ) ):
# ignore unused cases
if category.find( 'bai-tho' ) < 0: continue
readLabel = ReadLabel( category, dataset, enableMultiProcessing )
standardization = Standardization( readLabel[ 0 ] )
Plot( standardization, readLabel[ 1 ], dataset )
if __name__ == '__main__':
main()