Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
inovisao
pynovisao
Commits
6d9218ce
Commit
6d9218ce
authored
Aug 18, 2021
by
Diego André Sant'Ana
🤞
Browse files
fix classification CNN with h.5
parent
07d28e2b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
+21
-3
src/classification/cnn_keras.py
src/classification/cnn_keras.py
+20
-3
src/pynovisao.py
src/pynovisao.py
+1
-0
No files found.
src/classification/cnn_keras.py
View file @
6d9218ce
...
...
@@ -22,7 +22,7 @@ from PIL import Image
from
keras
import
applications
from
keras.preprocessing.image
import
ImageDataGenerator
from
keras
import
optimizers
from
keras.models
import
Model
,
load_model
from
keras.models
import
Model
from
keras.layers
import
Dropout
,
Flatten
,
Dense
from
keras.callbacks
import
ModelCheckpoint
,
TensorBoard
from
keras
import
backend
as
K
...
...
@@ -38,8 +38,8 @@ from collections import OrderedDict
from
util.config
import
Config
from
util.file_utils
import
File
from
util.utils
import
TimeUtils
from
tensorflow.keras.models
import
load_model
logger
=
logging
.
getLogger
(
'PIL'
)
logger
.
setLevel
(
logging
.
WARNING
)
...
...
@@ -60,7 +60,8 @@ dict_preprocessing[2] = applications.vgg19.preprocess_input, applications.vgg19.
dict_preprocessing
[
3
]
=
applications
.
resnet50
.
preprocess_input
,
applications
.
resnet50
.
decode_predictions
dict_preprocessing
[
4
]
=
applications
.
inception_v3
.
preprocess_input
,
applications
.
inception_v3
.
decode_predictions
dict_preprocessing
[
5
]
=
applications
.
mobilenet
.
preprocess_input
,
applications
.
mobilenet
.
decode_predictions
dict_preprocessing
[
6
]
=
applications
.
densenet
.
preprocess_input
,
applications
.
densenet
.
decode_predictions
dict_preprocessing
[
7
]
=
applications
.
resnet_v2
.
preprocess_input
,
applications
.
resnet_v2
.
decode_predictions
class
CNNKeras
(
Classifier
):
""" Class for CNN classifiers based on Keras applications """
...
...
@@ -370,6 +371,14 @@ class CNNKeras(Classifier):
self
.
app
=
5
model
=
applications
.
MobileNet
(
weights
=
"imagenet"
,
include_top
=
False
,
input_shape
=
(
IMG_WIDTH
,
IMG_HEIGHT
,
3
))
elif
self
.
architecture
.
value
==
"DenseNet201"
:
self
.
app
=
6
model
=
applications
.
DenseNet201
(
weights
=
"imagenet"
,
include_top
=
False
,
input_shape
=
(
IMG_WIDTH
,
IMG_HEIGHT
,
3
))
elif
self
.
architecture
.
value
==
"ResNet152V2"
:
self
.
app
=
7
model
=
applications
.
ResNet152V2
(
weights
=
"imagenet"
,
include_top
=
False
,
input_shape
=
(
IMG_WIDTH
,
IMG_HEIGHT
,
3
))
for
layer
in
model
.
layers
[:
int
(
len
(
model
.
layers
)
*
(
self
.
fine_tuning_rate
.
value
/
100.0
))]:
layer
.
trainable
=
False
...
...
@@ -399,6 +408,14 @@ class CNNKeras(Classifier):
self
.
app
=
5
model
=
applications
.
MobileNet
(
weights
=
None
,
include_top
=
False
,
input_shape
=
(
IMG_WIDTH
,
IMG_HEIGHT
,
3
))
elif
self
.
architecture
.
value
==
"DenseNet201"
:
self
.
app
=
6
model
=
applications
.
DenseNet201
(
weights
=
None
,
include_top
=
False
,
input_shape
=
(
IMG_WIDTH
,
IMG_HEIGHT
,
3
))
elif
self
.
architecture
.
value
==
"ResNet152V2"
:
self
.
app
=
7
model
=
applications
.
ResNet152V2
(
weights
=
None
,
include_top
=
False
,
input_shape
=
(
IMG_WIDTH
,
IMG_HEIGHT
,
3
))
for
layer
in
model
.
layers
:
layer
.
trainable
=
True
...
...
src/pynovisao.py
View file @
6d9218ce
...
...
@@ -619,6 +619,7 @@ class Act(object):
popup_info
+=
"%-16s%-16s%0.2f%%
\n
"
%
(
cl
[
"name"
].
value
,
str
(
len_classes
),
(
len_classes
*
100.0
)
/
len_total
)
print
(
popup_info
)
cv2
.
imwrite
(
"rf2000.png"
,
self
.
_image
)
self
.
tk
.
refresh_image
(
self
.
_image
)
self
.
tk
.
popup
(
popup_info
)
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment