Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2021-210
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-210
2021-210
Commits
3714b09d
Commit
3714b09d
authored
Nov 16, 2021
by
salukbawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update CNN model class with more diseases
parent
7760321d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
8 deletions
+29
-8
skin_disease/convolutional_neural_network.py
skin_disease/convolutional_neural_network.py
+21
-4
skin_disease/model loss.png
skin_disease/model loss.png
+0
-0
skin_disease/predict_image_class.py
skin_disease/predict_image_class.py
+8
-4
No files found.
skin_disease/convolutional_neural_network.py
View file @
3714b09d
# importing libraries
import
keras
,
tensorflow
import
numpy
as
np
from
keras.preprocessing.image
import
ImageDataGenerator
from
keras.models
import
Sequential
from
keras.layers
import
Conv2D
,
MaxPooling2D
from
keras.layers
import
Activation
,
Dropout
,
Flatten
,
Dense
from
keras
import
backend
as
K
import
matplotlib.pyplot
as
plt
img_width
,
img_height
=
350
,
350
...
...
@@ -39,6 +37,7 @@ model.add(MaxPooling2D(pool_size =(2, 2)))
model
.
add
(
Flatten
())
model
.
add
(
Dense
(
64
))
model
.
add
(
Activation
(
'relu'
))
model
.
add
(
Dropout
(
0.5
))
model
.
add
(
Dense
(
2
))
model
.
add
(
Activation
(
'softmax'
))
...
...
@@ -64,9 +63,27 @@ validation_generator = test_datagen.flow_from_directory(
target_size
=
(
img_width
,
img_height
),
batch_size
=
batch_size
,
class_mode
=
'sparse'
)
model
.
fit_generator
(
train_generator
,
history
=
model
.
fit_generator
(
train_generator
,
steps_per_epoch
=
nb_train_samples
//
batch_size
,
epochs
=
epochs
,
validation_data
=
validation_generator
,
validation_steps
=
nb_validation_samples
//
batch_size
)
model
.
save_weights
(
'model_saved.h5'
)
print
(
history
.
history
)
# summarize history for accuracy
plt
.
plot
(
history
.
history
[
'accuracy'
])
plt
.
plot
(
history
.
history
[
'val_accuracy'
])
plt
.
title
(
'model accuracy'
)
plt
.
ylabel
(
'accuracy'
)
plt
.
xlabel
(
'epoch'
)
plt
.
legend
([
'train'
,
'test'
],
loc
=
'upper left'
)
plt
.
show
()
# summarize history for loss
plt
.
plot
(
history
.
history
[
'loss'
])
plt
.
plot
(
history
.
history
[
'val_loss'
])
plt
.
title
(
'model loss'
)
plt
.
ylabel
(
'loss'
)
plt
.
xlabel
(
'epoch'
)
plt
.
legend
([
'train'
,
'test'
],
loc
=
'upper left'
)
plt
.
show
()
skin_disease/model loss.png
0 → 100644
View file @
3714b09d
24.6 KB
skin_disease/predict_image_class.py
View file @
3714b09d
...
...
@@ -9,9 +9,10 @@ from keras.layers import Dense, Dropout, Flatten
from
keras.models
import
Sequential
print
(
tensorflow
.
__version__
)
print
(
keras
.
__version__
)
def
predictImageClass
(
image
):
K
.
clear_session
()
tensorflow
.
reset_default_graph
()
#
tensorflow.reset_default_graph()
nb_train_samples
=
112
nb_validation_samples
=
20
...
...
@@ -65,9 +66,12 @@ def predictImageClass(image):
pred
=
modelI
.
predict
(
img
)
# pred = labels["label_names"][np.argmax(pred)]
print
(
pred
)
y
=
[
"
Ring worms"
,
"Sarcoptic & demodectic mange
"
]
y
=
[
"
Sarcoptic & demodectic mange"
,
"Ring worms
"
]
print
(
np
.
argmax
(
pred
))
print
(
y
[
np
.
argmax
(
pred
)])
return
y
[
np
.
argmax
(
pred
)]
return
{
"pred"
:
y
[
np
.
argmax
(
pred
)],
"accuracy"
:
str
(
pred
[
0
][
np
.
argmax
(
pred
)])
}
predictImageClass
(
"data/test/Ringworm/Ringworm1.jpg"
)
\ No newline at end of file
# predictImageClass("data/test/Ringworm/Ringworm1.jpg")
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