Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
22_23-J 52
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
22_23-J 52
22_23-J 52
Commits
e5a70592
Commit
e5a70592
authored
May 22, 2023
by
Chamodi Mandakini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Routes
parent
d6c34c3c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
routes.py
routes.py
+63
-0
No files found.
routes.py
0 → 100644
View file @
e5a70592
from
flask
import
render_template
,
request
from
app
import
app
import
numpy
as
np
# linear algebra
import
pandas
as
pd
# data processing, CSV file I/O (e.g. pd.read_csv)
import
os
import
cv2
from
pathlib
import
Path
import
pickle
import
tensorflow
as
tf
import
sklearn
@
app
.
route
(
'/skincancer'
)
def
skincancer
():
return
render_template
(
'skincancer.html'
)
def
predict2
(
img
):
model
=
tf
.
keras
.
models
.
load_model
(
'modelNew.h5'
)
pic
=
[]
img
=
cv2
.
resize
(
img
,
(
100
,
100
))
if
img
.
shape
[
2
]
==
1
:
img
=
np
.
dstack
([
img
,
img
,
img
])
img
=
np
.
array
(
img
)
img
=
img
/
255
# label = to_categorical(0, num_classes=2)
pic
.
append
(
img
)
# pic_labels.append(pneu)
pic1
=
np
.
array
(
pic
)
a
=
model
.
predict
(
pic1
)
print
(
a
.
argmax
())
predicts
=
a
.
argmax
()
predicts
if
predicts
==
0
:
return
"Melanocytic nevi"
elif
predicts
==
1
:
return
"Melanoma"
elif
predicts
==
2
:
return
"Benign keratosis-like lesions"
elif
predicts
==
3
:
return
"Basal cell carcinoma"
elif
predicts
==
4
:
return
"Actinic keratoses"
elif
predicts
==
5
:
return
"Vascular lesions"
else
:
return
"Dermatofibroma"
@
app
.
route
(
'/process_image_skin'
,
methods
=
[
'POST'
])
def
process_image_skin
():
if
request
.
method
==
'POST'
:
file
=
request
.
files
[
'file'
]
img_bytes
=
file
.
read
()
# Read image data as bytes
# Convert bytes to OpenCV image
img
=
cv2
.
imdecode
(
np
.
frombuffer
(
img_bytes
,
np
.
uint8
),
-
1
)
img
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2RGB
)
# Convert BGR to RGB
prediction
=
predict2
(
img
)
# Make prediction using img
return
render_template
(
'results.html'
,
result
=
prediction
)
return
'File uploaded successfully!'
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