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
8e8fb21b
Commit
8e8fb21b
authored
Oct 02, 2021
by
Kavindu Randika
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-it18141252' into 'master'
Dev it18141252 See merge request
!8
parents
347c156d
11fc9684
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
7 deletions
+33
-7
README.md
README.md
+14
-2
config/db.py
config/db.py
+3
-1
models/disease.py
models/disease.py
+2
-1
requirements.txt
requirements.txt
+0
-0
routes/prediction.py
routes/prediction.py
+14
-3
No files found.
README.md
View file @
8e8fb21b
...
...
@@ -13,9 +13,21 @@
-
.
\e
nv
\S
cripts
\a
ctivate
-
uvicorn main:app --reload
## Export Dependencies
-
.
\e
nv
\S
cripts
\a
ctivate
-
pip freeze > requirements.txt
test change
\ No newline at end of file
## Deploy to deta.sh
-
Install deta CLI
`iwr https://get.deta.dev/cli.ps1 -useb | iex`
-
Login to deta
`deta login`
-
Deploy
`deta new`
config/db.py
View file @
8e8fb21b
from
pymongo
import
MongoClient
conn
=
MongoClient
(
"mongodb+srv://skin-disease:skindis123@cluster0.bv8ia.mongodb.net/skinDiseaseDB?retryWrites=true&w=majority"
)
conn
=
MongoClient
(
"mongodb+srv://skin-disease:skindis123@cluster0.bv8ia.mongodb.net/skinDiseaseDB?retryWrites=true&w=majority"
,
tls
=
True
,
tlsAllowInvalidCertificates
=
True
)
db
=
conn
[
'skinDiseaseDB'
]
disease_collection
=
db
[
'disease'
]
#mongodb+srv://skin-disease:skindis123@cluster0.bv8ia.mongodb.net/test
\ No newline at end of file
models/disease.py
View file @
8e8fb21b
from
pydantic
import
BaseModel
from
typing
import
Optional
class
Disease
(
BaseModel
):
name
:
str
description
:
str
\ No newline at end of file
description
:
Optional
[
str
]
=
""
\ No newline at end of file
requirements.txt
View file @
8e8fb21b
B
absl-py
==0.14.0
...
...
routes/prediction.py
View file @
8e8fb21b
from
fastapi
import
APIRouter
,
File
,
UploadFile
from
pydantic
import
BaseModel
import
tensorflow
as
tf
from
tensorflow
import
keras
from
typing
import
List
...
...
@@ -7,10 +8,15 @@ import pandas as pd
import
numpy
as
np
import
json
from
keras.preprocessing
import
image
from
config.db
import
disease_collection
from
schemas.disease
import
diseasesEntity
prediction
=
APIRouter
()
class
Symptoms
(
BaseModel
):
symptoms
:
List
[
int
]
batch_size
=
32
img_height
=
180
img_width
=
180
...
...
@@ -36,12 +42,13 @@ def read_imagefile( image:UploadFile ):
return
None
# PREDICT DISEASE FROM SYMPTOMSES
@
prediction
.
post
(
'/api/predictions/symptoms'
)
async
def
predict_symptoms
(
symptoms
:
List
[
int
]
):
async
def
predict_symptoms
(
symptoms
:
Symptoms
):
try
:
data
=
load_data_json
(
'./data.json'
)
threshold
=
0.5
input
=
set
(
symptoms
)
input
=
set
(
symptoms
.
symptoms
)
output
=
[]
for
key
in
data
.
keys
():
numbers
=
[
int
(
i
)
for
i
in
key
.
split
(
','
)
if
int
(
i
)
!=
0
]
...
...
@@ -49,12 +56,16 @@ async def predict_symptoms(symptoms: List[int]):
score
=
len
(
list
(
input
&
set
(
numbers
)))
/
lenght
if
score
>=
threshold
:
output
.
append
(
data
.
get
(
key
))
diseases
=
diseasesEntity
(
disease_collection
.
find
({
"name"
:
{
"$in"
:
output
}}))
return
{
"success"
:
True
,
"result"
:
output
}
return
{
"success"
:
True
,
"result"
:
diseases
}
except
error
:
return
{
"success"
:
False
,
"msg"
:
error
}
# PREDICT DISEASE FROM PICTURES
@
prediction
.
post
(
'/api/predictions/picture'
)
async
def
predict_symptoms
(
req_file
:
UploadFile
=
File
(
...
)):
try
:
...
...
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