Spaces:
Runtime error
Runtime error
File size: 1,759 Bytes
a577b73 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
import streamlit as st
import streamlit.components.v1 as components
import pyvista as pv
from pyvista import examples
import numpy as np
from dcgan import DCGAN3D_G
import torch
import requests
url = "https://raw.githubusercontent.com/LukasMosser/PorousMediaGan/raw/master/checkpoints/berea/berea_generator_epoch_24.pth"
# If repo is private - we need to add a token in header:
resp = requests.get(url)
print(resp.status_code)
pv.set_plot_theme("document")
pl = pv.Plotter(shape=(1, 1),
window_size=(800, 800))
netG = DCGAN3D_G(64, 512, 1, 32, 1)
netG.load_state_dict(torch.load("./src/berea_generator_epoch_24.pth"))
z = torch.randn(1, 512, 5, 5, 5)
with torch.no_grad():
X = netG(z)
print(X.size())
print(X.min(), X.max())
st.image((X[0, 0, 32].numpy()+1)/2, output_format="png")
"""
data = examples.load_channels()
channels = data.threshold([0.9, 1.1])
print(channels)
bodies = channels.split_bodies()
# Now remove all bodies with a small volume
for key in bodies.keys():
b = bodies[key]
vol = b.volume
if vol < 1000.0:
del bodies[key]
continue
# Now lets add a volume array to all blocks
b.cell_data["TOTAL VOLUME"] = np.full(b.n_cells, vol)
for i, body in enumerate(bodies):
print(f"Body {i:02d} volume: {body.volume:.3f}")
pl.add_mesh(bodies)
pl.export_html('pyvista.html')
st.header("test html import")
view_width = 800
view_height = 800
HtmlFile = open("pyvista.html", 'r', encoding='utf-8')
source_code = HtmlFile.read()
components.html(source_code, width=view_width, height=view_height)
#snippet = embed.embed_snippet(views=view(reader.GetOutput()))
#html = embed.html_template.format(title="", snippet=snippet)
#components.html(html, width=view_width, height=view_height)""" |