Spaces:
Sleeping
Sleeping
Upload 8 files
Browse files- Models/Eye_diseases.h5 +3 -0
- Models/Fracture_detection.h5 +3 -0
- Models/all-in-one.h5 +3 -0
- Models/chest_cls_model.h5 +3 -0
- Models/kidney_stone.h5 +3 -0
- Models/skin_cancer.h5 +3 -0
- app.py +56 -0
- model.py +81 -0
Models/Eye_diseases.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5d0f68e95d3253ad2710cc751439e79953795f0325cb07d01bc319c572a134f8
|
3 |
+
size 1660429600
|
Models/Fracture_detection.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c5cb95a39fa1115c6ad3e97a071a09162734d8a019bd309c1d8f97630e77dde8
|
3 |
+
size 53242608
|
Models/all-in-one.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1bbf56489ced275993d802e266ce51dd26b954e79ac45c9472da58fead91d293
|
3 |
+
size 18905360
|
Models/chest_cls_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d60fc8431da21f814615b0b05e96e494db19c0258ddf8a04dd884d6ffdd471f8
|
3 |
+
size 1660429600
|
Models/kidney_stone.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:007496ea3955d1c108283fc7dd4e480ba50ede662b3d0082c0c921fd43e5f67e
|
3 |
+
size 1660429600
|
Models/skin_cancer.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:892397295533c66b1c57b8bdaa44d8f93068a4b7740b3c2bab3859267da7456f
|
3 |
+
size 726490264
|
app.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import io
|
2 |
+
import os
|
3 |
+
import numpy as np
|
4 |
+
import streamlit as st
|
5 |
+
import requests
|
6 |
+
from PIL import Image
|
7 |
+
from model import classify
|
8 |
+
import cv2
|
9 |
+
|
10 |
+
@st.cache(allow_output_mutation=True)
|
11 |
+
# def get_model():
|
12 |
+
# return bone_frac()
|
13 |
+
|
14 |
+
# pred_model = get_model()
|
15 |
+
# pred_model=bone_frac()
|
16 |
+
|
17 |
+
def predict():
|
18 |
+
c=classify('tmp.jpg')
|
19 |
+
st.markdown('#### Predicted Captions:')
|
20 |
+
st.write(c)
|
21 |
+
|
22 |
+
st.title('Image Captioner')
|
23 |
+
img_url = st.text_input(label='Enter Image URL')
|
24 |
+
|
25 |
+
if (img_url != "") and (img_url != None):
|
26 |
+
img = Image.open(requests.get(img_url, stream=True).raw)
|
27 |
+
img = img.convert('RGB')
|
28 |
+
st.image(img)
|
29 |
+
img.save('tmp.jpg')
|
30 |
+
predict()
|
31 |
+
os.remove('tmp.jpg')
|
32 |
+
|
33 |
+
hide_streamlit_style = """
|
34 |
+
<style>
|
35 |
+
#MainMenu {visibility: hidden;}
|
36 |
+
footer {visibility: hidden;}
|
37 |
+
</style>
|
38 |
+
"""
|
39 |
+
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
40 |
+
# st.markdown('<center style="opacity: 70%">OR</center>', unsafe_allow_html=True)
|
41 |
+
img_upload = st.file_uploader(label='Upload Image', type=['jpg', 'png', 'jpeg'])
|
42 |
+
|
43 |
+
if img_upload != None:
|
44 |
+
img = img_upload.read()
|
45 |
+
img = Image.open(io.BytesIO(img))
|
46 |
+
img = img.convert('RGB')
|
47 |
+
img=np.asarray(img)
|
48 |
+
print(img)
|
49 |
+
# img=cv2.imread(img)
|
50 |
+
# img.save('tmp.jpg')
|
51 |
+
st.image(img)
|
52 |
+
c=classify(img)
|
53 |
+
st.markdown('#### Predicted Captions:')
|
54 |
+
st.write(c)
|
55 |
+
# predict()
|
56 |
+
# os.remove('tmp.jpg')
|
model.py
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import tensorflow as tf
|
2 |
+
import cv2
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
|
6 |
+
def classify(img):
|
7 |
+
im = img
|
8 |
+
lt = ["other","Bone","Brain","eye","kidney","chest","skin"]
|
9 |
+
im = cv2.resize(im,(52,52))
|
10 |
+
model = tf.keras.models.load_model("Models/all-in-one.h5")
|
11 |
+
result = model.predict(np.array([im]))
|
12 |
+
a = np.argmax(result)
|
13 |
+
c=""
|
14 |
+
if a==0:
|
15 |
+
return "Enter the medical Image"
|
16 |
+
if a==1:
|
17 |
+
c = bone_net(img)
|
18 |
+
if a==2:
|
19 |
+
c = brain_net(img)
|
20 |
+
if a==3:
|
21 |
+
c = Eye_net(img)
|
22 |
+
if a==4:
|
23 |
+
c = kidney_net(img)
|
24 |
+
if a==5:
|
25 |
+
c = chest_net(img)
|
26 |
+
if a==6:
|
27 |
+
c = skin_net(img)
|
28 |
+
return c
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
def bone_net(img):
|
33 |
+
img = cv2.resize(img,(224,224))
|
34 |
+
model = tf.keras.models.load_model("Models/Fracture_detection.h5")
|
35 |
+
result = model.predict(np.array([img]))
|
36 |
+
op=""
|
37 |
+
if result[0]<0.5:
|
38 |
+
op="Fracture"
|
39 |
+
else:
|
40 |
+
op="Normal"
|
41 |
+
return op
|
42 |
+
|
43 |
+
def brain_net(img):
|
44 |
+
lt = ['pituitary', 'notumor', 'meningioma', 'glioma']
|
45 |
+
img = cv2.resize(img,(224,224))
|
46 |
+
model = tf.keras.models.load_model("Models/model_brain_tumur.h5")
|
47 |
+
result = model.predict(np.array([img]))
|
48 |
+
ans = np.argmax(result)
|
49 |
+
return lt[ans]
|
50 |
+
|
51 |
+
def chest_net(img):
|
52 |
+
lt = ['PNEUMONIA', 'NORMAL']
|
53 |
+
img = cv2.resize(img,(224,224))
|
54 |
+
model = tf.keras.models.load_model("Models/chest_cls_model.h5")
|
55 |
+
result = model.predict(np.array([img]))
|
56 |
+
ans = np.argmax(result)
|
57 |
+
return lt[ans]
|
58 |
+
|
59 |
+
def Eye_net(img):
|
60 |
+
lt = ['glaucoma', 'normal', 'diabetic_retinopathy', 'cataract']
|
61 |
+
img = cv2.resize(img,(224,224))
|
62 |
+
model = tf.keras.models.load_model("Models/Eye_diseases.h5")
|
63 |
+
result = model.predict(np.array([img]))
|
64 |
+
ans = np.argmax(result)
|
65 |
+
return lt[ans]
|
66 |
+
|
67 |
+
def kidney_net(img):
|
68 |
+
lt = ['Cyst', 'Tumor', 'Stone', 'Normal']
|
69 |
+
img = cv2.resize(img,(224,224))
|
70 |
+
model = tf.keras.models.load_model("Models/kidney_stone.h5")
|
71 |
+
result = model.predict(np.array([img]))
|
72 |
+
ans = np.argmax(result)
|
73 |
+
return lt[ans]
|
74 |
+
|
75 |
+
def skin_net(img):
|
76 |
+
lt = ['pigmented benign keratosis', 'melanoma', 'vascular lesion', 'actinic keratosis', 'squamous cell carcinoma', 'basal cell carcinoma', 'seborrheic keratosis', 'dermatofibroma', 'nevus']
|
77 |
+
img = cv2.resize(img,(224,224))
|
78 |
+
model = tf.keras.models.load_model("Models/skin_cancer.h5")
|
79 |
+
result = model.predict(np.array([img]))
|
80 |
+
ans = np.argmax(result)
|
81 |
+
return lt[ans]
|