Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
Skin disease Server
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
Skin disease
Skin disease Server
Commits
b18efe96
Commit
b18efe96
authored
Oct 06, 2021
by
Kavindu Randika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Diseases with descriptions
parent
8e8fb21b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
68 deletions
+28
-68
requirements.txt
requirements.txt
+3
-42
routes/prediction.py
routes/prediction.py
+23
-23
schemas/disease.py
schemas/disease.py
+2
-3
No files found.
requirements.txt
View file @
b18efe96
absl-py
==0.14.0
asgiref
==3.4.1
astunparse
==1.6.3
cachetools
==4.2.2
certifi
==2021.5.30
charset-normalizer
==2.0.6
clang
==5.0
click
==8.0.1
colorama
==0.4.4
dnspython
==
2.1
.0
dnspython
==
1.16
.0
fastapi
==0.68.1
flatbuffers
==1.12
gast
==0.4.0
google-auth
==1.35.0
google-auth-oauthlib
==0.4.6
google-pasta
==0.2.0
grpcio
==1.40.0
h11
==0.12.0
h5py
==3.1.0
idna
==3.2
keras
==2.6.0
Keras-Preprocessing
==1.1.2
Markdown
==3.3.4
numpy
==1.19.5
oauthlib
==3.1.1
opt-einsum
==3.3.0
pandas
==1.3.3
Pillow
==8.3.2
protobuf
==3.18.0
pyasn1
==0.4.8
pyasn1-modules
==0.2.8
pydantic
==1.8.2
pymongo
==3.12.0
python-dateutil
==2.8.2
python-multipart
==0.0.5
pytz
==2021.1
requests
==2.26.0
requests-oauthlib
==1.3.0
rsa
==4.7.2
six
==1.15.0
six
==1.16.0
starlette
==0.14.2
tensorboard
==2.6.0
tensorboard-data-server
==0.6.1
tensorboard-plugin-wit
==1.8.0
tensorflow-cpu
==2.6.0
tensorflow-estimator
==2.6.0
termcolor
==1.1.0
typing-extensions
==3.7.4.3
urllib3
==1.26.7
typing-extensions
==3.10.0.2
uvicorn
==0.15.0
Werkzeug
==2.0.1
wrapt
==1.12.1
\ No newline at end of file
routes/prediction.py
View file @
b18efe96
from
fastapi
import
APIRouter
,
File
,
UploadFile
from
pydantic
import
BaseModel
import
tensorflow
as
tf
from
tensorflow
import
keras
#
import tensorflow as tf
#
from tensorflow import keras
from
typing
import
List
from
os
import
error
import
pandas
as
pd
import
numpy
as
np
#
import pandas as pd
#
import numpy as np
import
json
from
keras.preprocessing
import
image
#
from keras.preprocessing import image
from
config.db
import
disease_collection
from
schemas.disease
import
diseasesEntity
...
...
@@ -57,7 +57,7 @@ async def predict_symptoms(symptoms: Symptoms):
if
score
>=
threshold
:
output
.
append
(
data
.
get
(
key
))
diseases
=
diseasesEntity
(
disease_collection
.
find
({
"name"
:
{
"$in"
:
output
}}))
diseases
=
diseasesEntity
(
disease_collection
.
find
({
"name"
:
{
"$in"
:
output
}}))
return
{
"success"
:
True
,
"result"
:
diseases
}
...
...
@@ -69,30 +69,30 @@ async def predict_symptoms(symptoms: Symptoms):
@
prediction
.
post
(
'/api/predictions/picture'
)
async
def
predict_symptoms
(
req_file
:
UploadFile
=
File
(
...
)):
try
:
img
=
read_imagefile
(
req_file
)
#
img = read_imagefile(req_file)
if
img
is
None
:
return
{
"success"
:
False
,
"msg"
:
'Not a valid data format'
}
#
if img is None:
#
return {"success": False, "msg": 'Not a valid data format'}
model_path
=
'./xception'
image_path
=
"./temp_images/temp_image.jpg"
#
model_path = './xception'
#
image_path = "./temp_images/temp_image.jpg"
#load model
model
=
keras
.
models
.
load_model
(
model_path
)
#
#
load model
#
model = keras.models.load_model(model_path)
#load data
load_img
=
image
.
load_img
(
image_path
,
target_size
=
(
img_height
,
img_width
))
img_array
=
image
.
img_to_array
(
load_img
)
img_array
=
tf
.
expand_dims
(
img_array
,
0
)
#
#
load data
#
load_img = image.load_img(image_path, target_size=(img_height, img_width))
#
img_array = image.img_to_array(load_img)
#
img_array = tf.expand_dims(img_array, 0)
#predict
predictions
=
model
.
predict
(
img_array
,
batch_size
)
score
=
tf
.
nn
.
softmax
(
predictions
[
0
])
#
#
predict
#
predictions = model.predict(img_array, batch_size)
#
score = tf.nn.softmax(predictions[0])
#return
prediction
=
class_names
[
np
.
argmax
(
score
)]
#
#
return
#
prediction = class_names[np.argmax(score)]
return
{
"success"
:
True
,
"result"
:
prediction
}
return
{
"success"
:
True
,
"result"
:
req_file
.
filename
}
except
error
:
return
{
"success"
:
False
,
"msg"
:
error
}
...
...
schemas/disease.py
View file @
b18efe96
def
diseaseEntity
(
item
)
->
dict
:
return
{
"id"
:
str
(
item
[
"id"
]),
def
diseaseEntity
(
item
)
->
dict
:
return
{
"name"
:
item
[
"name"
],
"description"
:
item
[
"description"
],
}
...
...
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