Spaces:
Runtime error
Runtime error
lmoss
commited on
Commit
·
87dfdc2
1
Parent(s):
883839d
exception handling
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@ import numpy as np
|
|
| 8 |
import numpy.typing as npt
|
| 9 |
from dcgan import DCGAN3D_G
|
| 10 |
import pathlib
|
|
|
|
| 11 |
pv.start_xvfb()
|
| 12 |
|
| 13 |
|
|
@@ -130,32 +131,35 @@ def main():
|
|
| 130 |
slices, mesh, dist = create_uniform_mesh_marching_cubes(img)
|
| 131 |
|
| 132 |
pv.set_plot_theme("document")
|
| 133 |
-
|
| 134 |
window_size=(view_width, view_height))
|
| 135 |
-
_ =
|
| 136 |
-
|
| 137 |
slices_html = DummyWriteable()
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
-
|
| 141 |
window_size=(view_width, view_height))
|
| 142 |
-
_ =
|
| 143 |
mesh_html = DummyWriteable()
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
st.header("2D Cross-Section of Generated Volume")
|
| 147 |
fig = create_matplotlib_figure(img, img.shape[0]//2)
|
| 148 |
st.pyplot(fig=fig)
|
| 149 |
|
| 150 |
-
source_code = slices_html.html
|
| 151 |
st.header("3D Intersections")
|
| 152 |
-
components.html(
|
| 153 |
st.markdown("_Click and drag to spin, right click to shift._")
|
| 154 |
|
| 155 |
|
| 156 |
-
source_code = mesh_html.html
|
| 157 |
st.header("3D Pore Space Mesh")
|
| 158 |
-
components.html(
|
| 159 |
st.markdown("_Click and drag to spin, right click to shift._")
|
| 160 |
|
| 161 |
st.markdown("""
|
|
|
|
| 8 |
import numpy.typing as npt
|
| 9 |
from dcgan import DCGAN3D_G
|
| 10 |
import pathlib
|
| 11 |
+
import time
|
| 12 |
pv.start_xvfb()
|
| 13 |
|
| 14 |
|
|
|
|
| 131 |
slices, mesh, dist = create_uniform_mesh_marching_cubes(img)
|
| 132 |
|
| 133 |
pv.set_plot_theme("document")
|
| 134 |
+
pl1 = pv.Plotter(shape=(1, 1),
|
| 135 |
window_size=(view_width, view_height))
|
| 136 |
+
_ = pl1.add_mesh(slices, cmap="gray")
|
|
|
|
| 137 |
slices_html = DummyWriteable()
|
| 138 |
+
try:
|
| 139 |
+
pl1.export_html(slices_html)
|
| 140 |
+
except RuntimeError as e:
|
| 141 |
+
print(e)
|
| 142 |
|
| 143 |
+
pl2 = pv.Plotter(shape=(1, 1),
|
| 144 |
window_size=(view_width, view_height))
|
| 145 |
+
_ = pl2.add_mesh(mesh, scalars=dist)
|
| 146 |
mesh_html = DummyWriteable()
|
| 147 |
+
try:
|
| 148 |
+
pl2.export_html(mesh_html)
|
| 149 |
+
except RuntimeError as e:
|
| 150 |
+
print(e)
|
| 151 |
|
| 152 |
st.header("2D Cross-Section of Generated Volume")
|
| 153 |
fig = create_matplotlib_figure(img, img.shape[0]//2)
|
| 154 |
st.pyplot(fig=fig)
|
| 155 |
|
|
|
|
| 156 |
st.header("3D Intersections")
|
| 157 |
+
components.html(slices_html.html, width=view_width, height=view_height)
|
| 158 |
st.markdown("_Click and drag to spin, right click to shift._")
|
| 159 |
|
| 160 |
|
|
|
|
| 161 |
st.header("3D Pore Space Mesh")
|
| 162 |
+
components.html(mesh_html.html, width=view_width, height=view_height)
|
| 163 |
st.markdown("_Click and drag to spin, right click to shift._")
|
| 164 |
|
| 165 |
st.markdown("""
|