fabiencasenave commited on
Commit
5eb7f8a
1 Parent(s): d88747e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -1,8 +1,8 @@
1
  import gradio as gr
2
- # import pickle
3
- # from datasets import load_from_disk
4
  from plaid.containers.sample import Sample
5
- # import pyvista as pv
6
 
7
  import numpy as np
8
  import pyrender
@@ -15,24 +15,23 @@ import os
15
  os.environ["PYOPENGL_PLATFORM"] = "egl"
16
 
17
 
18
- os.system("wget https://zenodo.org/records/10124594/files/Tensile2d.tar.gz")
19
- os.system("tar -xvf Tensile2d.tar.gz")
20
 
21
- # FOLDER = "plot"
22
 
23
- # dataset = load_from_disk("Rotor37")
24
 
25
  field_names_train = ["sig11", "sig22", "sig12", "U1", "U2", "q"]
26
 
27
 
28
 
29
 
30
-
31
-
32
-
33
  def sample_info(sample_id_str, fieldn):
34
 
35
- plaid_sample = Sample.load_from_dir(f"Tensile2d/dataset/samples/sample_"+str(sample_id_str).zfill(9))
 
 
 
36
  nodes = plaid_sample.get_nodes()
37
  field = plaid_sample.get_field(fieldn)
38
  if nodes.shape[1] == 2:
 
1
  import gradio as gr
2
+ import pickle
3
+ from datasets import load_dataset
4
  from plaid.containers.sample import Sample
5
+
6
 
7
  import numpy as np
8
  import pyrender
 
15
  os.environ["PYOPENGL_PLATFORM"] = "egl"
16
 
17
 
18
+ # os.system("wget https://zenodo.org/records/10124594/files/Tensile2d.tar.gz")
19
+ # os.system("tar -xvf Tensile2d.tar.gz")
20
 
21
+ hf_dataset = load_dataset(“PLAID-datasets/Tensile2d”, split=“all_samples”)
22
 
 
23
 
24
  field_names_train = ["sig11", "sig22", "sig12", "U1", "U2", "q"]
25
 
26
 
27
 
28
 
 
 
 
29
  def sample_info(sample_id_str, fieldn):
30
 
31
+ sample_ = hf_dataset[int(sample_id_str)]["sample"]
32
+ plaid_sample = Sample.model_validate(pickle.loads(sample_))
33
+ # plaid_sample = Sample.load_from_dir(f"Tensile2d/dataset/samples/sample_"+str(sample_id_str).zfill(9))
34
+
35
  nodes = plaid_sample.get_nodes()
36
  field = plaid_sample.get_field(fieldn)
37
  if nodes.shape[1] == 2: