-
Notifications
You must be signed in to change notification settings - Fork 0
/
operations.py
50 lines (39 loc) · 1.46 KB
/
operations.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
import convert_data
import train_image_classifier_gen
import export_inference_graph
import freeze_graph
import evaluation
import os
import json
import time
d_a = {}
with open('default_arguments.json', 'r') as js:
d_a = json.load(js)
def train(dt):
if not 'dataset_dir' in dt:
return "No dataset directory specified"
for key in dt:
d_a[key] = dt[key]
d_a['freeze_dict']['input_checkpoint'] = os.path.join(d_a['train_dir'], 'model.ckpt-'+ str(d_a['max_number_of_steps']))
start = time.time()
train_size, val_size, num_classes = convert_data.run(dt['dataset_dir'], d_a['dataset_name'],
d_a['validation_percentage'], d_a['num_shards'])
start_train = time.time()
train_image_classifier_gen.main(d_a['train_dir'], d_a['num_clones'], d_a['clone_on_cpu'],
train_size, val_size, num_classes, d_a['worker_replicas'],
d_a['log_every_n_steps'], d_a['save_interval_secs'], d_a['weight_decay'],
d_a['optimization'], d_a['learning_rate'], d_a['moving_average_decay'],
d_a['dataset'], d_a['max_number_of_steps'], d_a['checkpoint'])
end_train = time.time()
export_inference_graph.main(d_a['export'], train_size, val_size, num_classes)
freeze_graph.main(d_a['freeze_dict'])
end = time.time()
train_time = end_train - start_train
full_time = end - start
rest = full_time - train_time
return { 'training_time': train_time,
'full_time': full_time,
'rest': rest
}
def inference(image):
return evaluation.main(image)