Spaces:
Running
Running
Commit
·
25515ea
0
Parent(s):
Duplicate from NVASAIKUMAR/ModelD
Browse filesCo-authored-by: VENKATA ANAND SAI KUMAR NARLA <[email protected]>
- .gitattributes +34 -0
- README.md +13 -0
- all-in-one.h5 +3 -0
- app.py +56 -0
- brain.h5 +3 -0
- chest.h5 +3 -0
- covid_pred.sav +0 -0
- diab_pred.sav +0 -0
- eye .h5 +3 -0
- fracture.h5 +3 -0
- heartatt_pred.sav +0 -0
- kidney.h5 +3 -0
- model.py +81 -0
- requirements.txt +8 -0
- skin.h5 +3 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: ModelD
|
3 |
+
emoji: 👁
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: gray
|
6 |
+
sdk: streamlit
|
7 |
+
sdk_version: 1.19.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: NVASAIKUMAR/ModelD
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
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
|
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')
|
brain.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:44ed5812c6454304fb43a6870cba8f21996195825e15399baabe3c175e6db8ef
|
3 |
+
size 18905360
|
chest.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3615404f9a0d2221c53f706bf39c0d4a72187b51fa4a88508e7d24ea883cdcec
|
3 |
+
size 18905408
|
covid_pred.sav
ADDED
Binary file (12 kB). View file
|
|
diab_pred.sav
ADDED
Binary file (60.5 kB). View file
|
|
eye .h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7f28ef2cecfc306c57073e822ee5ead4679eeb626023e1964495ddcbb76d7a42
|
3 |
+
size 18905320
|
fracture.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2be347c748e7d70039a3286a11047c502a9db9a4fca6ad7d67bacd32048fbbfe
|
3 |
+
size 18905296
|
heartatt_pred.sav
ADDED
Binary file (119 kB). View file
|
|
kidney.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c2595174821c906b783bfbfb853d50cc2f81dc293863017de8457655195dcd4c
|
3 |
+
size 18905296
|
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("all-in-one.h5",compile=False)
|
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(im)
|
18 |
+
if a==2:
|
19 |
+
c = brain_net(im)
|
20 |
+
if a==3:
|
21 |
+
c = Eye_net(im)
|
22 |
+
if a==4:
|
23 |
+
c = kidney_net(im)
|
24 |
+
if a==5:
|
25 |
+
c = chest_net(im)
|
26 |
+
if a==6:
|
27 |
+
c = skin_net(im)
|
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("fracture.h5",compile=False)
|
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,(52,52))
|
46 |
+
model = tf.keras.models.load_model("brain.h5",compile=False)
|
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("chest.h5",compile=False)
|
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("eye.h5",compile=False)
|
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("kidney.h5",compile=False)
|
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("skin.h5",compile=False)
|
79 |
+
result = model.predict(np.array([img]))
|
80 |
+
ans = np.argmax(result)
|
81 |
+
return lt[ans]
|
requirements.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
numpy==1.22.3
|
2 |
+
pandas==1.4.3
|
3 |
+
pandas_stubs==1.2.0.56
|
4 |
+
Pillow==9.2.0
|
5 |
+
requests==2.27.1
|
6 |
+
streamlit==1.11.1
|
7 |
+
tensorflow==2.9.1
|
8 |
+
opencv-python
|
skin.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bd1cc593dfe9f2d76723ae397f3145737cb60ab3b2df8e42dd8a07686983c444
|
3 |
+
size 18905296
|