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
5073225c
Commit
5073225c
authored
Nov 25, 2021
by
salukbawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create cnn model with more diseases
parent
3714b09d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
33 deletions
+61
-33
skin_disease/API.py
skin_disease/API.py
+28
-0
skin_disease/convolutional_neural_network.py
skin_disease/convolutional_neural_network.py
+9
-9
skin_disease/model accuracy.png
skin_disease/model accuracy.png
+0
-0
skin_disease/model loss.png
skin_disease/model loss.png
+0
-0
skin_disease/predict_image_class.py
skin_disease/predict_image_class.py
+24
-24
No files found.
skin_disease/API.py
0 → 100644
View file @
5073225c
import
os
import
predict_image_class
from
flask
import
Flask
,
request
from
flask_cors
import
CORS
,
cross_origin
from
flask
import
send_file
app
=
Flask
(
__name__
)
cors
=
CORS
(
app
)
uploadPath
=
"uploads"
@
app
.
route
(
'/predict'
,
methods
=
[
'POST'
])
@
cross_origin
()
def
uploadImage
():
print
(
os
.
getcwd
())
f
=
request
.
files
[
'file'
]
splits
=
f
.
filename
.
split
(
"/"
)
print
(
splits
[
len
(
splits
)
-
1
])
# os.remove(os.path.join(uploadPath, "upload.jpg"))
f
.
save
(
os
.
path
.
join
(
uploadPath
,
"upload.jpg"
))
return
predict_image_class
.
predictImageClass
(
"uploads/upload.jpg"
)
@
app
.
route
(
'/getImage'
,
methods
=
[
'POST'
,
'GET'
])
@
cross_origin
()
def
getImage
():
return
send_file
(
"uploads/upload.jpg"
,
mimetype
=
'image/gif'
)
if
__name__
==
'__main__'
:
app
.
run
(
debug
=
True
,
port
=
5000
,
host
=
"0.0.0.0"
)
skin_disease/convolutional_neural_network.py
View file @
5073225c
...
...
@@ -9,11 +9,11 @@ import matplotlib.pyplot as plt
img_width
,
img_height
=
350
,
350
train_data_dir
=
'data/train'
validation_data_dir
=
'data/test'
nb_train_samples
=
1
68
nb_validation_samples
=
2
0
epochs
=
20
train_data_dir
=
'
v2_
data/train'
validation_data_dir
=
'
v2_
data/test'
nb_train_samples
=
1
50
nb_validation_samples
=
3
0
epochs
=
15
batch_size
=
20
if
K
.
image_data_format
()
==
'channels_first'
:
...
...
@@ -26,20 +26,20 @@ model.add(Conv2D(32, (2, 2), input_shape = input_shape))
model
.
add
(
Activation
(
'relu'
))
model
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
.
add
(
Conv2D
(
32
,
(
2
,
2
)))
model
.
add
(
Conv2D
(
64
,
(
2
,
2
)))
model
.
add
(
Activation
(
'relu'
))
model
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
.
add
(
Conv2D
(
64
,
(
2
,
2
)))
model
.
add
(
Conv2D
(
32
,
(
2
,
2
)))
model
.
add
(
Activation
(
'relu'
))
model
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
.
add
(
Flatten
())
model
.
add
(
Dense
(
64
))
model
.
add
(
Dense
(
32
))
model
.
add
(
Activation
(
'relu'
))
model
.
add
(
Dropout
(
0.5
))
model
.
add
(
Dense
(
2
))
model
.
add
(
Dense
(
3
))
model
.
add
(
Activation
(
'softmax'
))
model
.
compile
(
loss
=
'sparse_categorical_crossentropy'
,
...
...
skin_disease/model accuracy.png
0 → 100644
View file @
5073225c
43.1 KB
skin_disease/model loss.png
View replaced file @
3714b09d
View file @
5073225c
24.6 KB
|
W:
|
H:
28 KB
|
W:
|
H:
2-up
Swipe
Onion skin
skin_disease/predict_image_class.py
View file @
5073225c
import
random
from
keras.layers
import
Activation
import
keras
import
numpy
as
np
...
...
@@ -14,10 +16,6 @@ def predictImageClass(image):
K
.
clear_session
()
# tensorflow.reset_default_graph()
nb_train_samples
=
112
nb_validation_samples
=
20
epochs
=
10
batch_size
=
2
img_width
,
img_height
=
350
,
350
if
K
.
image_data_format
()
==
'channels_first'
:
...
...
@@ -25,31 +23,32 @@ def predictImageClass(image):
else
:
input_shape
=
(
img_width
,
img_height
,
3
)
modelI
=
Sequential
()
modelI
.
add
(
Conv2D
(
32
,
(
2
,
2
),
input_shape
=
input_shape
))
modelI
.
add
(
Activation
(
'relu'
))
modelI
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
=
Sequential
()
model
.
add
(
Conv2D
(
32
,
(
2
,
2
),
input_shape
=
input_shape
))
model
.
add
(
Activation
(
'relu'
))
model
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
.
add
(
Conv2D
(
64
,
(
2
,
2
)))
model
.
add
(
Activation
(
'relu'
))
model
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
I
.
add
(
Conv2D
(
32
,
(
2
,
2
)))
model
I
.
add
(
Activation
(
'relu'
))
model
I
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
.
add
(
Conv2D
(
32
,
(
2
,
2
)))
model
.
add
(
Activation
(
'relu'
))
model
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
I
.
add
(
Conv2D
(
64
,
(
2
,
2
)
))
model
I
.
add
(
Activation
(
'relu'
))
model
I
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)
))
model
.
add
(
Flatten
(
))
model
.
add
(
Dense
(
32
))
model
.
add
(
Activation
(
'relu'
))
modelI
.
add
(
Flatten
())
modelI
.
add
(
Dense
(
64
))
modelI
.
add
(
Activation
(
'relu'
))
modelI
.
add
(
Dropout
(
0.5
))
modelI
.
add
(
Dense
(
2
))
modelI
.
add
(
Activation
(
'softmax'
))
model
.
add
(
Dropout
(
0.5
))
model
.
add
(
Dense
(
3
))
model
.
add
(
Activation
(
'softmax'
))
model
I
.
compile
(
loss
=
'sparse_categorical_crossentropy'
,
model
.
compile
(
loss
=
'sparse_categorical_crossentropy'
,
optimizer
=
'adam'
,
metrics
=
[
'accuracy'
])
model
I
.
load_weights
(
'model_saved.h5'
)
model
.
load_weights
(
'model_saved.h5'
)
sess
=
keras
.
backend
.
get_session
()
# image = request.args.get('image', default = 1, type = str)
...
...
@@ -63,12 +62,13 @@ def predictImageClass(image):
img
=
img
.
eval
(
session
=
sess
)
# convert to numpy array
img
=
np
.
expand_dims
(
img
,
0
)
# make 'batch' of 1
pred
=
model
I
.
predict
(
img
)
pred
=
model
.
predict
(
img
)
# pred = labels["label_names"][np.argmax(pred)]
print
(
pred
)
y
=
[
"
Sarcoptic & demodectic mange"
,
"Ring
worms"
]
y
=
[
"
Demodatic"
,
"Dermatites"
,
"ring
worms"
]
print
(
np
.
argmax
(
pred
))
print
(
y
[
np
.
argmax
(
pred
)])
i
=
random
.
randint
(
0
,
1
)
return
{
"pred"
:
y
[
np
.
argmax
(
pred
)],
"accuracy"
:
str
(
pred
[
0
][
np
.
argmax
(
pred
)])
...
...
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