Spaces:
Runtime error
Runtime error
lmoss
commited on
Commit
·
9bc9fb6
1
Parent(s):
8150c29
added better formatting
Browse files
app.py
CHANGED
@@ -9,6 +9,25 @@ import streamlit.components.v1 as components
|
|
9 |
|
10 |
st.title("Generating Porous Media with GANs")
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
url = "https://github.com/LukasMosser/PorousMediaGan/blob/master/checkpoints/berea/berea_generator_epoch_24.pth?raw=true"
|
13 |
|
14 |
# If repo is private - we need to add a token in header:
|
@@ -46,6 +65,7 @@ slices = grid.slice_orthogonal()
|
|
46 |
mesh = grid.contour(1, values, method='marching_cubes', rng=[1, 0], preference="points")
|
47 |
dist = np.linalg.norm(mesh.points, axis=1)
|
48 |
|
|
|
49 |
pl = pv.Plotter(shape=(1, 1),
|
50 |
window_size=(400, 400))
|
51 |
_ = pl.add_mesh(slices, cmap="gray")
|
@@ -57,14 +77,30 @@ _ = pl.add_mesh(mesh, scalars=dist)
|
|
57 |
pl.export_html('mesh.html')
|
58 |
|
59 |
|
60 |
-
st.header("test html import")
|
61 |
view_width = 400
|
62 |
view_height = 400
|
63 |
|
64 |
HtmlFile = open("slices.html", 'r', encoding='utf-8')
|
65 |
source_code = HtmlFile.read()
|
66 |
-
components.html(source_code, width=view_width, height=view_height)
|
67 |
|
|
|
|
|
|
|
68 |
HtmlFile = open("mesh.html", 'r', encoding='utf-8')
|
69 |
source_code = HtmlFile.read()
|
|
|
|
|
70 |
components.html(source_code, width=view_width, height=view_height)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
st.title("Generating Porous Media with GANs")
|
11 |
|
12 |
+
st.markdown(
|
13 |
+
"""
|
14 |
+
### Author
|
15 |
+
_Lukas Mosser (2022)_ - :bird:[porestar](https://twitter.com/porestar)
|
16 |
+
|
17 |
+
## Description
|
18 |
+
This is a demo of the Generative Adversarial Network (GAN, [Goodfellow 2014](https://arxiv.org/abs/1406.2661)) trained for our publication [PorousMediaGAN](https://github.com/LukasMosser/PorousMediaGan)
|
19 |
+
published in Physical Review E ([Mosser et. al 2017](https://journals.aps.org/pre/abstract/10.1103/PhysRevE.96.043309))
|
20 |
+
|
21 |
+
The model is a pretrained 3D Deep Convolutional GAN ([Radford 2015](https://arxiv.org/abs/1511.06434)) that generates a volumetric image of a porous medium, here a Berea sandstone, from a set of pretrained weights.
|
22 |
+
|
23 |
+
## The Demo
|
24 |
+
Slices through the 3D volume are rendered using [PyVista](https://www.pyvista.org/) and [PyThreeJS](https://pythreejs.readthedocs.io/en/stable/)
|
25 |
+
|
26 |
+
The model itself currently runs on the :hugging_face: [Huggingface Spaces](https://huggingface.co/spaces) instance.
|
27 |
+
Future migration to the :hugging_face: [Huggingface Models](https://huggingface.co/models) repository is possible.
|
28 |
+
"""
|
29 |
+
, unsafe_allow_html=True)
|
30 |
+
|
31 |
url = "https://github.com/LukasMosser/PorousMediaGan/blob/master/checkpoints/berea/berea_generator_epoch_24.pth?raw=true"
|
32 |
|
33 |
# If repo is private - we need to add a token in header:
|
|
|
65 |
mesh = grid.contour(1, values, method='marching_cubes', rng=[1, 0], preference="points")
|
66 |
dist = np.linalg.norm(mesh.points, axis=1)
|
67 |
|
68 |
+
|
69 |
pl = pv.Plotter(shape=(1, 1),
|
70 |
window_size=(400, 400))
|
71 |
_ = pl.add_mesh(slices, cmap="gray")
|
|
|
77 |
pl.export_html('mesh.html')
|
78 |
|
79 |
|
|
|
80 |
view_width = 400
|
81 |
view_height = 400
|
82 |
|
83 |
HtmlFile = open("slices.html", 'r', encoding='utf-8')
|
84 |
source_code = HtmlFile.read()
|
|
|
85 |
|
86 |
+
st.header("3D Intersections")
|
87 |
+
components.html(source_code, width=view_width, height=view_height)
|
88 |
+
st.markdown("_Click and drag to spin, right click to shift._")
|
89 |
HtmlFile = open("mesh.html", 'r', encoding='utf-8')
|
90 |
source_code = HtmlFile.read()
|
91 |
+
|
92 |
+
st.header("3D Pore Space Mesh")
|
93 |
components.html(source_code, width=view_width, height=view_height)
|
94 |
+
st.markdown("_Click and drag to spin, right click to shift._")
|
95 |
+
|
96 |
+
st.markdown("""
|
97 |
+
## Citation
|
98 |
+
If you use our code for your own research, we would be grateful if you cite our publication:
|
99 |
+
```
|
100 |
+
@article{pmgan2017,
|
101 |
+
title={Reconstruction of three-dimensional porous media using generative adversarial neural networks},
|
102 |
+
author={Mosser, Lukas and Dubrule, Olivier and Blunt, Martin J.},
|
103 |
+
journal={arXiv preprint arXiv:1704.03225},
|
104 |
+
year={2017}
|
105 |
+
}```
|
106 |
+
""")
|