Update pages/01_🦷 Segment.py
Browse files- pages/01_🦷 Segment.py +15 -7
pages/01_🦷 Segment.py
CHANGED
|
@@ -6,6 +6,7 @@ import numpy as np
|
|
| 6 |
from sklearn import neighbors
|
| 7 |
from scipy.spatial import distance_matrix
|
| 8 |
from pygco import cut_from_graph
|
|
|
|
| 9 |
import open3d as o3d
|
| 10 |
import matplotlib.pyplot as plt
|
| 11 |
import matplotlib.colors as mcolors
|
|
@@ -586,7 +587,7 @@ def mesh_to_points_main(jaw, pcd_points, center_points, labels):
|
|
| 586 |
instances_labels = upsample_label.copy()
|
| 587 |
# '''
|
| 588 |
# o3d.io.write_point_cloud(os.path.join(save_path, 'upsample_' + name + '.pcd'), new_pcd, write_ascii=True)
|
| 589 |
-
for i in range(0, upsample_label.shape[0]):
|
| 590 |
if jaw == 'upper':
|
| 591 |
if (upsample_label[i] >= 1) and (upsample_label[i] <= 8):
|
| 592 |
upsample_label[i] = upsample_label[i] + 10
|
|
@@ -855,7 +856,7 @@ def segmentation_main(obj_path):
|
|
| 855 |
# Show the plot
|
| 856 |
#plotter.show()
|
| 857 |
## Send to streamlit
|
| 858 |
-
with st.expander("View Segmentation Result", expanded=False):
|
| 859 |
stpyvista(plotter)
|
| 860 |
|
| 861 |
# Configure Streamlit page
|
|
@@ -869,7 +870,7 @@ class Segment(TeethApp):
|
|
| 869 |
def build_app(self):
|
| 870 |
|
| 871 |
st.title("Segment Intra-oral Scans")
|
| 872 |
-
st.markdown("
|
| 873 |
|
| 874 |
inputs = st.radio(
|
| 875 |
"Select scan for segmentation:",
|
|
@@ -882,8 +883,11 @@ class Segment(TeethApp):
|
|
| 882 |
plotter = pv.Plotter()
|
| 883 |
|
| 884 |
# Add the mesh to the plotter
|
| 885 |
-
plotter.add_mesh(mesh, color='white', show_edges=
|
| 886 |
-
segment = st.button(
|
|
|
|
|
|
|
|
|
|
| 887 |
with st.expander("View Scan", expanded=False):
|
| 888 |
stpyvista(plotter)
|
| 889 |
|
|
@@ -906,14 +910,18 @@ class Segment(TeethApp):
|
|
| 906 |
plotter = pv.Plotter()
|
| 907 |
|
| 908 |
# Add the mesh to the plotter
|
| 909 |
-
plotter.add_mesh(mesh, color='white', show_edges=
|
| 910 |
-
segment = st.button(
|
|
|
|
|
|
|
|
|
|
| 911 |
with st.expander("View Scan", expanded=False):
|
| 912 |
stpyvista(plotter)
|
| 913 |
|
| 914 |
if segment:
|
| 915 |
segmentation_main(obj_path)
|
| 916 |
|
|
|
|
| 917 |
|
| 918 |
|
| 919 |
|
|
|
|
| 6 |
from sklearn import neighbors
|
| 7 |
from scipy.spatial import distance_matrix
|
| 8 |
from pygco import cut_from_graph
|
| 9 |
+
import streamlit_ext as ste
|
| 10 |
import open3d as o3d
|
| 11 |
import matplotlib.pyplot as plt
|
| 12 |
import matplotlib.colors as mcolors
|
|
|
|
| 587 |
instances_labels = upsample_label.copy()
|
| 588 |
# '''
|
| 589 |
# o3d.io.write_point_cloud(os.path.join(save_path, 'upsample_' + name + '.pcd'), new_pcd, write_ascii=True)
|
| 590 |
+
for i in stqdm(range(0, upsample_label.shape[0])):
|
| 591 |
if jaw == 'upper':
|
| 592 |
if (upsample_label[i] >= 1) and (upsample_label[i] <= 8):
|
| 593 |
upsample_label[i] = upsample_label[i] + 10
|
|
|
|
| 856 |
# Show the plot
|
| 857 |
#plotter.show()
|
| 858 |
## Send to streamlit
|
| 859 |
+
with st.expander("**View Segmentation Result** - ", expanded=False):
|
| 860 |
stpyvista(plotter)
|
| 861 |
|
| 862 |
# Configure Streamlit page
|
|
|
|
| 870 |
def build_app(self):
|
| 871 |
|
| 872 |
st.title("Segment Intra-oral Scans")
|
| 873 |
+
st.markdown("Identify and segment teeth. Segmentation is performed using MeshSegNet, a deep learning model trained on both upper and lower jaws.")
|
| 874 |
|
| 875 |
inputs = st.radio(
|
| 876 |
"Select scan for segmentation:",
|
|
|
|
| 883 |
plotter = pv.Plotter()
|
| 884 |
|
| 885 |
# Add the mesh to the plotter
|
| 886 |
+
plotter.add_mesh(mesh, color='white', show_edges=False)
|
| 887 |
+
segment = st.button(
|
| 888 |
+
"✔️ Submit",
|
| 889 |
+
help="Submit 3D scan for segmentation",
|
| 890 |
+
)
|
| 891 |
with st.expander("View Scan", expanded=False):
|
| 892 |
stpyvista(plotter)
|
| 893 |
|
|
|
|
| 910 |
plotter = pv.Plotter()
|
| 911 |
|
| 912 |
# Add the mesh to the plotter
|
| 913 |
+
plotter.add_mesh(mesh, color='white', show_edges=False)
|
| 914 |
+
segment = st.button(
|
| 915 |
+
"✔️ Submit",
|
| 916 |
+
help="Submit 3D scan for segmentation",
|
| 917 |
+
)
|
| 918 |
with st.expander("View Scan", expanded=False):
|
| 919 |
stpyvista(plotter)
|
| 920 |
|
| 921 |
if segment:
|
| 922 |
segmentation_main(obj_path)
|
| 923 |
|
| 924 |
+
|
| 925 |
|
| 926 |
|
| 927 |
|