lmoss commited on
Commit
4274c54
·
1 Parent(s): f54e2aa

added dual pane view

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -16,13 +16,9 @@ resp = requests.get(url)
16
 
17
  with open('berea_generator_epoch_24.pth', 'wb') as f:
18
  f.write(resp.content)
19
- time.sleep(5)
20
-
21
- st.text(resp.status_code)
22
 
23
  pv.set_plot_theme("document")
24
- pl = pv.Plotter(shape=(2, 1),
25
- window_size=(800, 800))
26
 
27
  netG = DCGAN3D_G(64, 512, 1, 32, 1)
28
  netG.load_state_dict(torch.load("berea_generator_epoch_24.pth", map_location=torch.device('cpu')))
@@ -30,8 +26,6 @@ z = torch.randn(1, 512, 1, 1, 1)
30
  with torch.no_grad():
31
  X = netG(z)
32
 
33
- st.image((X[0, 0, 32].numpy()+1)/2, output_format="png")
34
-
35
  img = 1-(X[0, 0].numpy()+1)/2
36
 
37
  a = 0.9
@@ -52,16 +46,25 @@ slices = grid.slice_orthogonal()
52
  mesh = grid.contour(1, values, method='marching_cubes', rng=[1, 0], preference="points")
53
  dist = np.linalg.norm(mesh.points, axis=1)
54
 
55
- pl.subplot(0, 0)
 
56
  _ = pl.add_mesh(slices, cmap="gray")
 
 
 
57
  pl.subplot(1, 0)
58
  _ = pl.add_mesh(mesh, scalars=dist)
59
- pl.export_html('pyvista.html')
 
60
 
61
  st.header("test html import")
62
- view_width = 800
63
- view_height = 800
64
- HtmlFile = open("pyvista.html", 'r', encoding='utf-8')
 
65
  source_code = HtmlFile.read()
 
66
 
 
 
67
  components.html(source_code, width=view_width, height=view_height)
 
16
 
17
  with open('berea_generator_epoch_24.pth', 'wb') as f:
18
  f.write(resp.content)
 
 
 
19
 
20
  pv.set_plot_theme("document")
21
+
 
22
 
23
  netG = DCGAN3D_G(64, 512, 1, 32, 1)
24
  netG.load_state_dict(torch.load("berea_generator_epoch_24.pth", map_location=torch.device('cpu')))
 
26
  with torch.no_grad():
27
  X = netG(z)
28
 
 
 
29
  img = 1-(X[0, 0].numpy()+1)/2
30
 
31
  a = 0.9
 
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")
52
+
53
+ pl = pv.Plotter(shape=(1, 1),
54
+ window_size=(400, 400))
55
  pl.subplot(1, 0)
56
  _ = 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)