Spaces:
Sleeping
Sleeping
Arslan7788
commited on
Commit
•
d20682a
1
Parent(s):
67e7425
Upload 8 files
Browse files- .gitattributes +3 -0
- 107.png +3 -0
- 108.png +3 -0
- 109.png +3 -0
- README.md +18 -5
- app.py +99 -0
- dental_xray_seg.h5 +3 -0
- gitattributes.txt +27 -0
- requirements.txt +7 -0
.gitattributes
CHANGED
@@ -35,3 +35,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
35 |
ML[[:space:]]MODEL/107.png filter=lfs diff=lfs merge=lfs -text
|
36 |
ML[[:space:]]MODEL/108.png filter=lfs diff=lfs merge=lfs -text
|
37 |
ML[[:space:]]MODEL/109.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
35 |
ML[[:space:]]MODEL/107.png filter=lfs diff=lfs merge=lfs -text
|
36 |
ML[[:space:]]MODEL/108.png filter=lfs diff=lfs merge=lfs -text
|
37 |
ML[[:space:]]MODEL/109.png filter=lfs diff=lfs merge=lfs -text
|
38 |
+
107.png filter=lfs diff=lfs merge=lfs -text
|
39 |
+
108.png filter=lfs diff=lfs merge=lfs -text
|
40 |
+
109.png filter=lfs diff=lfs merge=lfs -text
|
107.png
ADDED
Git LFS Details
|
108.png
ADDED
Git LFS Details
|
109.png
ADDED
Git LFS Details
|
README.md
CHANGED
@@ -1,12 +1,25 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: green
|
6 |
sdk: streamlit
|
7 |
-
sdk_version: 1.21.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
title: Segmentation Of Teeth In Panoramic X Ray Image Using U Net
|
3 |
+
emoji: 🐠
|
4 |
+
colorFrom: indigo
|
5 |
colorTo: green
|
6 |
sdk: streamlit
|
|
|
7 |
app_file: app.py
|
8 |
pinned: false
|
9 |
---
|
10 |
|
11 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
12 |
+
|
13 |
+
|
14 |
+
The authors of this article are Selahattin Serdar Helli and Andaç Hamamcı with the Department of Biomedical Engineering, Faculty of Engineering, Yeditepe University, Istanbul, Turkey
|
15 |
+
|
16 |
+
```
|
17 |
+
@article{helli10tooth,
|
18 |
+
title={Tooth Instance Segmentation on Panoramic Dental Radiographs Using U-Nets and Morphological Processing},
|
19 |
+
author={HELL{\.I}, Serdar and HAMAMCI, Anda{\c{c}}},
|
20 |
+
journal={D{\"u}zce {\"U}niversitesi Bilim ve Teknoloji Dergisi},
|
21 |
+
volume={10},
|
22 |
+
number={1},
|
23 |
+
pages={39--50}
|
24 |
+
}
|
25 |
+
```
|
app.py
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
import tensorflow as tf
|
4 |
+
from PIL import Image
|
5 |
+
import numpy as np
|
6 |
+
import cv2
|
7 |
+
from huggingface_hub import from_pretrained_keras
|
8 |
+
|
9 |
+
|
10 |
+
try:
|
11 |
+
model=from_pretrained_keras("SerdarHelli/Segmentation-of-Teeth-in-Panoramic-X-ray-Image-Using-U-Net")
|
12 |
+
except:
|
13 |
+
model=tf.keras.models.load_model("dental_xray_seg.h5")
|
14 |
+
pass
|
15 |
+
|
16 |
+
st.header("Dental X-RAY")
|
17 |
+
|
18 |
+
examples=["107.png"]
|
19 |
+
st.markdown(unsafe_allow_html=True)
|
20 |
+
|
21 |
+
|
22 |
+
def load_image(image_file):
|
23 |
+
img = Image.open(image_file)
|
24 |
+
return img
|
25 |
+
|
26 |
+
def convert_one_channel(img):
|
27 |
+
#some images have 3 channels , although they are grayscale image
|
28 |
+
if len(img.shape)>2:
|
29 |
+
img= cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
30 |
+
return img
|
31 |
+
else:
|
32 |
+
return img
|
33 |
+
|
34 |
+
def convert_rgb(img):
|
35 |
+
#some images have 3 channels , although they are grayscale image
|
36 |
+
if len(img.shape)==2:
|
37 |
+
img= cv2.cvtColor(img,cv2.COLOR_GRAY2RGB)
|
38 |
+
return img
|
39 |
+
else:
|
40 |
+
return img
|
41 |
+
|
42 |
+
|
43 |
+
st.subheader("Upload Dental X-ray Image Image Hear")
|
44 |
+
image_file = st.file_uploader("Upload Images", type=["png","jpg","jpeg"])
|
45 |
+
|
46 |
+
|
47 |
+
col1, col2, col3 = st.columns(3)
|
48 |
+
with col1:
|
49 |
+
ex=load_image(examples[0])
|
50 |
+
st.image(ex,width=200)
|
51 |
+
if st.button('Example 1'):
|
52 |
+
image_file=examples[0]
|
53 |
+
|
54 |
+
with col2:
|
55 |
+
ex1=load_image(examples[1])
|
56 |
+
st.image(ex1,width=200)
|
57 |
+
if st.button('Example 2'):
|
58 |
+
image_file=examples[1]
|
59 |
+
|
60 |
+
|
61 |
+
with col3:
|
62 |
+
ex2=load_image(examples[2])
|
63 |
+
st.image(ex2,width=200)
|
64 |
+
if st.button('Example 3'):
|
65 |
+
image_file=examples[2]
|
66 |
+
|
67 |
+
|
68 |
+
if image_file is not None:
|
69 |
+
|
70 |
+
img=load_image(image_file)
|
71 |
+
|
72 |
+
st.text("Making A Prediction ....")
|
73 |
+
st.image(img,width=850)
|
74 |
+
|
75 |
+
img=np.asarray(img)
|
76 |
+
|
77 |
+
img_cv=convert_one_channel(img)
|
78 |
+
img_cv=cv2.resize(img_cv,(512,512), interpolation=cv2.INTER_LANCZOS4)
|
79 |
+
img_cv=np.float32(img_cv/255)
|
80 |
+
|
81 |
+
img_cv=np.reshape(img_cv,(1,512,512,1))
|
82 |
+
prediction=model.predict(img_cv)
|
83 |
+
predicted=prediction[0]
|
84 |
+
predicted = cv2.resize(predicted, (img.shape[1],img.shape[0]), interpolation=cv2.INTER_LANCZOS4)
|
85 |
+
mask=np.uint8(predicted*255)#
|
86 |
+
_, mask = cv2.threshold(mask, thresh=0, maxval=255, type=cv2.THRESH_BINARY+cv2.THRESH_OTSU)
|
87 |
+
kernel =( np.ones((5,5), dtype=np.float32))
|
88 |
+
mask=cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernel,iterations=1 )
|
89 |
+
mask=cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel,iterations=1 )
|
90 |
+
cnts,hieararch=cv2.findContours(mask,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
|
91 |
+
output = cv2.drawContours(convert_rgb(img), cnts, -1, (255, 0, 0) , 3)
|
92 |
+
|
93 |
+
|
94 |
+
if output is not None :
|
95 |
+
st.subheader("Predicted Image")
|
96 |
+
st.write(output.shape)
|
97 |
+
st.image(output,width=850)
|
98 |
+
|
99 |
+
st.text("DONE ! ....")
|
dental_xray_seg.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:31baf3a5726d594850cf09370b47087480f917fff42a243f9aa1363fcd5b51b4
|
3 |
+
size 161359384
|
gitattributes.txt
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 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 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
imutils
|
2 |
+
numpy
|
3 |
+
Pillow
|
4 |
+
scipy
|
5 |
+
streamlit
|
6 |
+
tensorflow
|
7 |
+
opencv-python-headless
|