-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Feature : Prescription Digitization
- Loading branch information
1 parent
1db38ea
commit a6db437
Showing
62 changed files
with
1,216 additions
and
658 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
configs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,4 +104,5 @@ venv.bak/ | |
# mypy | ||
.mypy_cache/ | ||
.platform/local | ||
Pipfile.lock | ||
Pipfile.lock | ||
configs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__()}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__()}} |
Oops, something went wrong.