Skip to content

Commit

Permalink
New Feature : Prescription Digitization
Browse files Browse the repository at this point in the history
  • Loading branch information
mrakesh0608 committed May 23, 2023
1 parent 1db38ea commit a6db437
Show file tree
Hide file tree
Showing 62 changed files with 1,216 additions and 658 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
configs
16 changes: 13 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ If you have a suggestion that would make this better, please fork the repo and c
## Setup - Front End
- Change directory into frontend `cd Sahaay/frontEnd`
- Install dependencies `npm i`
- Copy your configuration files into configs folder
- It contains 2 files.
- Rename to `google-services.json` for Android.
- Rename to `GoogleService-Info.plist` for IOS.


### Development Build
- For Android, download development build apk from this [link](https://expo.dev/artifacts/eas/46C15VEcskVvueo11M3TA5.apk).<div align='center'>OR</div>Build your own development apk using `npm run build-dev-apk` & download it from [Expo dev](https://expo.dev/).
- For Android, download development build apk from this [link](https://expo.dev/artifacts/eas/f1XcZvGjKjD47iykSFr7xt.apk).<div align='center'>OR</div>Build your own development apk using `npm run build-dev-apk` & download it from [Expo dev](https://expo.dev/).
- Install development build apk in your Android device.
- Start metro bundler `npm start`
- Start metro bundler with empty cache `npm run start-c`
Expand All @@ -30,16 +35,21 @@ If you have a suggestion that would make this better, please fork the repo and c

## Setup - Back End
- Change directory into backend `cd Sahaay/backEnd`
- Copy your configuration files into configs folder
- It contains 2 files.
- Rename to `gCloud.json` for Google's Vision API
- Rename to `serviceAccount.json` for rest applications
- Start Server using
```powershell
uvicorn --app-dir src server:app --reload --host [your-host-ip or 127.0.0.1]
# If all packages are already installed in your system
uvicorn --app-dir src server:app --reload --host [your-host-ip]
```

<p align='center'>or</p>

```powershell
pipenv install
pipenv run python src/server.py
pipenv run uvicorn --app-dir src server:app --reload --host [your-host-ip]
```

### Deploy Server to [Platform.sh](https://platform.sh/)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
Sahaay is an application which Digitize, Analyze & Predict Medical Reports using Deep Learning. It provides a solution to digitize the handwritten prescriptions, lab reports and detect various diseases.

## Main Features
- Prescription Digitization (in development)
- Prescription Digitization
- Brain Tumor Classification
- Kidney Stone Classification
- Skin Disease Classification
- Calories Estimation
- Digital Prescription (in development)
- Digital Prescription
- Search About Medicine

## App Features
Expand All @@ -42,7 +42,7 @@ Sahaay is an application which Digitize, Analyze & Predict Medical Reports using
- Share your profile & reports with other users

## ⬇️ Download Android App
- Download Sahaay app using this [link](https://expo.dev/artifacts/eas/qfrEemJyBC8d9EYU9bvyHX.apk).
- Download Sahaay app using this [link](https://expo.dev/artifacts/eas/bPMpoC94ycbrSUm9U9LgfF.apk).
- See screenshots of this app [here](./SCREENSHOTS.md).
## 🔧 Tools/Technologies Used

Expand Down
3 changes: 2 additions & 1 deletion backEnd/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,5 @@ venv.bak/
# mypy
.mypy_cache/
.platform/local
Pipfile.lock
Pipfile.lock
configs
6 changes: 4 additions & 2 deletions backEnd/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ verify_ssl = true
[dev-packages]

[packages]
google-cloud-vision = "*"
fastapi = "*"
uvicorn = "*"
firebase-admin = "*"
openai = "*"
opencv-python = "*"
scikit-image = "*"
tensorflow = "*"
uvicorn = "*"

[requires]
python_version = "3.11"
python_version = "3.11"
File renamed without changes.
85 changes: 0 additions & 85 deletions backEnd/src/routers/brainTumorDetection.py

This file was deleted.

63 changes: 63 additions & 0 deletions backEnd/src/routers/brain_tumor_detection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from fastapi import APIRouter
from pydantic import BaseModel

from util.predictions_analyzer import predictions_analyzer
import util.myfirebase as myfirebase

from keras.models import load_model
from skimage import io
import cv2

router = APIRouter(prefix="/brain-tumor-detection", tags=["brain"])


class Item(BaseModel):
uid: str
img_url: str


global graph, sess

model = load_model("src/models/brain_tumor.h5")

img_size = 200
classes = {0: "Glioma", 1: "Meningioma", 2: "Tumor Not Detected", 3: "Pituitary"}


def predict_class(image):
img = io.imread(image)
img = cv2.resize(img, (img_size, img_size)) / 255.0

predictions = (model.predict(img.reshape(1, img_size, img_size, 3)) * 100.0).round(
2
)

return predictions_analyzer(predictions=predictions, classes=classes)


@router.post("/")
async def main(item: Item):
try:
uid = item.uid
img_url = item.img_url

label, accuracy = predict_class(img_url)

doc_id = myfirebase.saveReport(
uid,
{
"title": "Brain Tumor Detection",
"result": label,
"img_url": img_url,
"isDetected": True
if label != "Tumor Not Detected"
else False,
"accuracy": accuracy,
},
)

return {"data": {"id": doc_id}}

except Exception as e:
print(e)
return {"error": {"message": e.__str__()}}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def main(item: Item):

nut = json["results"][0]["items"][0]["nutrition"]

# convert SI Unit to human readable units & concat unit
doc_id = myfirebase.saveReport(
uid,
{
Expand Down
80 changes: 0 additions & 80 deletions backEnd/src/routers/kidneyStoneDetection.py

This file was deleted.

58 changes: 58 additions & 0 deletions backEnd/src/routers/kidney_stone_detection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from fastapi import APIRouter
from pydantic import BaseModel

from util.predictions_analyzer import predictions_analyzer
import util.myfirebase as myfirebase

from keras.models import load_model
from skimage import io
import cv2

router = APIRouter(prefix="/kidney-stone-detection", tags=["kidney"])


class Item(BaseModel):
uid: str
img_url: str


model = load_model("src/models/kidney_stone.h5")
img_size = 200
classes = {0: "Cyst", 1: "Normal", 2: "Stone", 3: "Tumor"}


def predict_class(image):
img = io.imread(image)
img = cv2.resize(img, (img_size, img_size)) / 255.0

predictions = (model.predict(img.reshape(1, img_size, img_size, 3)) * 100.0).round(
2
)

return predictions_analyzer(predictions=predictions, classes=classes)


@router.post("/")
async def main(item: Item):
try:
uid = item.uid
img_url = item.img_url

label, accuracy = predict_class(img_url)

doc_id = myfirebase.saveReport(
uid,
{
"title": "Kidney Stone Detection",
"result": label,
"img_url": img_url,
"isDetected": True if label != "Normal" else False,
"accuracy": accuracy,
},
)

return {"data": {"id": doc_id}}

except Exception as e:
print(e)
return {"error": {"message": e.__str__()}}
Loading

0 comments on commit a6db437

Please sign in to comment.