-
Notifications
You must be signed in to change notification settings - Fork 0
/
modelos.py
90 lines (73 loc) · 3.12 KB
/
modelos.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
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 2 11:57:45 2021
@author: fabio
"""
from keras.models import Sequential
from keras.layers import Conv2D
from keras.layers import MaxPooling2D
from keras.layers import Flatten
from keras.layers import Dense
def modelo(opcao, average_image_size):
if opcao == 1:
# ultimo modelo testado TCC
model = Sequential()
model.add(Conv2D(64, (3, 3), input_shape = average_image_size, activation = 'relu'))
model.add(MaxPooling2D(pool_size = (2, 2)))
model.add(Conv2D(32, (3, 3), activation = 'relu'))
model.add(MaxPooling2D(pool_size = (2, 2)))
model.add(Conv2D(16, (3, 3), activation = 'relu'))
model.add(MaxPooling2D(pool_size = (2, 2)))
model.add(Flatten())
model.add(Dense(units = 256, activation = 'relu'))
model.add(Dense(units = 1, activation = 'sigmoid'))
return model
if opcao == 2:
# modelo 3 artigo
model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape = average_image_size, activation = 'relu'))
model.add(MaxPooling2D(pool_size = (2, 2)))
model.add(Conv2D(32, (3, 3), activation = 'relu'))
model.add(MaxPooling2D(pool_size = (2, 2)))
model.add(Conv2D(32, (3, 3), activation = 'relu'))
model.add(MaxPooling2D(pool_size = (2, 2)))
model.add(Flatten())
model.add(Dense(units = 256, activation = 'relu'))
model.add(Dense(units = 1, activation = 'sigmoid'))
return model
if opcao == 3:
# modelo 2 artigo
model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape = average_image_size, activation = 'relu'))
model.add(MaxPooling2D(pool_size = (2, 2)))
model.add(Conv2D(32, (3, 3), activation = 'relu'))
model.add(MaxPooling2D(pool_size = (2, 2)))
model.add(Flatten())
model.add(Dense(units = 256, activation = 'relu'))
model.add(Dense(units = 1, activation = 'sigmoid'))
return model
if opcao == 4:
# modelo 1 artigo
model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape = average_image_size, activation = 'relu'))
model.add(MaxPooling2D(pool_size = (2, 2)))
model.add(Flatten())
model.add(Dense(units = 256, activation = 'relu'))
model.add(Dense(units = 1, activation = 'sigmoid'))
return model
#-----------TESTE---------------
if opcao == 5:
# modelo 1 artigo
model = Sequential()
model.add(Conv2D(64, (3, 3), input_shape = average_image_size, activation = 'relu'))
model.add(MaxPooling2D(pool_size = (2, 2)))
model.add(Conv2D(32, (3, 3), activation = 'relu'))
model.add(MaxPooling2D(pool_size = (2, 2)))
model.add(Conv2D(16, (3, 3), activation = 'relu'))
model.add(MaxPooling2D(pool_size = (2, 2)))
model.add(Flatten())
model.add(Dense(units = 256, activation = 'relu'))
model.add(Dense(units = 1, activation = 'sigmoid'))
return model
def get_modelo_nome(k):
return 'model_'+str(k)+'.h5'