-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathconfig_1.py
94 lines (89 loc) · 2.41 KB
/
config_1.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# -*- coding: utf-8 -*-
import os
os.environ["CUDA_VISIBLE_DEVICES"]="1"
import tensorflow as tf
from keras import backend as K
from keras.optimizers import Adam
from keras.layers import Lambda
import albumentations as albu
from keras_metrics import *
config = tf.ConfigProto()
config.gpu_options.allow_growth=True
sess = tf.Session(config=config)
K.set_session(sess)
kmetrics={"class_output":['acc',f1score]}
customs_func = {"f1score": f1score}
POS = 1 #positive class
NEG = 0 #negative clas
batch_size = 128
NUM_EPOCHS = 10
nchannels=3 #number of channels
image_size_w_p = 96 #image´s width for registration plate
image_size_h_p = 48 #image´s height for registration plate
image_size_w_c = 64 #image´s width for vehicle´s shape
image_size_h_c = 64 #image´s height for vehicle´s shape
path = "data"
folder_cross1 = '%s/dataset2/Camera1' % (path)
folder_cross2 = '%s/dataset2/Camera2' % (path)
plt_name="classes"
car_name="classes_carros"
plt_folder="*/classes"
car_folder="*/classes_carros"
ocr_file = '%s/OCR/output.txt' % (path)
metadata_length = 35
tam_max = 3
L1_layer = Lambda(lambda tensor:K.abs(tensor[0] - tensor[1]))
train_augs = [[],[],[],[],[],[]]
test_augs = [[],[],[],[]]
keys = ['Set01','Set02','Set03','Set04','Set05']
seq_car = albu.Compose(
[
albu.IAACropAndPad(px=(0, 8)),
albu.IAAAffine(
scale=(0.8, 1.2),
shear=(-8, 8),
order=[0,1],
cval=(0),
mode='constant'),
albu.ToFloat(max_value=255)
],p=0.7
)
seq_car2 = albu.Compose(
[
albu.IAACropAndPad(px=(0, 8)),
albu.IAAAffine(
scale=(0.8, 1.2),
shear=(-8, 8),
order=[0,1],
cval=(0),
mode='constant'),
],p=0.7
)
seq_plate = albu.Compose(
[
albu.IAAAffine(
scale=(0.8, 1.2),
translate_percent=(-0.1, 0.1),
rotate=(-5, 5),
shear=(-16, 16),
order=[0,1],
cval=(0),
mode='constant'),
#albu.IAAAdd((-10,10)),
albu.ToFloat(max_value=255)
],p=0.7
)
AUGMENTATIONS_TEST = albu.Compose([
albu.ToFloat(max_value=255)
])
for i in range(tam_max):
train_augs[0].append(seq_plate)
train_augs[1].append(seq_plate)
train_augs[2].append(seq_car)
train_augs[3].append(seq_car)
train_augs[4].append(seq_car2)
train_augs[5].append(seq_car2)
test_augs[0].append(AUGMENTATIONS_TEST)
test_augs[1].append(AUGMENTATIONS_TEST)
test_augs[2].append(AUGMENTATIONS_TEST)
test_augs[3].append(AUGMENTATIONS_TEST)