Commit 8e8fb21b authored by Kavindu Randika's avatar Kavindu Randika

Merge branch 'dev-it18141252' into 'master'

Dev it18141252

See merge request !8
parents 347c156d 11fc9684
......@@ -13,9 +13,21 @@
- .\env\Scripts\activate
- uvicorn main:app --reload
## Export Dependencies
- .\env\Scripts\activate
- 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`
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
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
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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment