Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,11 @@ nb_samples = 1000
|
|
25 |
field_names_train = ["Density", "Pressure", "Temperature"]
|
26 |
|
27 |
|
|
|
|
|
|
|
|
|
|
|
28 |
def sample_info(sample_id_str, fieldn):
|
29 |
|
30 |
sample_ = hf_dataset[int(sample_id_str)]["sample"]
|
@@ -77,10 +82,26 @@ def sample_info(sample_id_str, fieldn):
|
|
77 |
color, _ = r.render(scene)
|
78 |
|
79 |
|
80 |
-
|
81 |
str__ = f"Training sample {sample_id_str}\n"
|
82 |
str__ += str(plaid_sample)+"\n"
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
return str__, color
|
86 |
|
@@ -88,17 +109,17 @@ def sample_info(sample_id_str, fieldn):
|
|
88 |
if __name__ == "__main__":
|
89 |
|
90 |
with gr.Blocks() as demo:
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
99 |
d1.input(sample_info, [d1, d2], [output1, output2])
|
100 |
d2.input(sample_info, [d1, d2], [output1, output2])
|
101 |
|
102 |
-
|
103 |
demo.launch()
|
104 |
|
|
|
25 |
field_names_train = ["Density", "Pressure", "Temperature"]
|
26 |
|
27 |
|
28 |
+
_HEADER_ = '''
|
29 |
+
<h2><b>Visualization demo of <a href='https://huggingface.co/datasets/PLAID-datasets/Rotor37' target='_blank'><b>Rotor37 dataset</b></b></h2>
|
30 |
+
'''
|
31 |
+
|
32 |
+
|
33 |
def sample_info(sample_id_str, fieldn):
|
34 |
|
35 |
sample_ = hf_dataset[int(sample_id_str)]["sample"]
|
|
|
82 |
color, _ = r.render(scene)
|
83 |
|
84 |
|
|
|
85 |
str__ = f"Training sample {sample_id_str}\n"
|
86 |
str__ += str(plaid_sample)+"\n"
|
87 |
+
|
88 |
+
if len(hf_dataset.description['in_scalars_names'])>0:
|
89 |
+
str__ += "\ninput scalars:\n"
|
90 |
+
for sname in hf_dataset.description['in_scalars_names']:
|
91 |
+
str__ += f"- {sname}: {plaid_sample.get_scalar(sname)}\n"
|
92 |
+
if len(hf_dataset.description['out_scalars_names'])>0:
|
93 |
+
str__ += "\noutput scalars:\n"
|
94 |
+
for sname in hf_dataset.description['out_scalars_names']:
|
95 |
+
str__ += f"- {sname}: {plaid_sample.get_scalar(sname)}\n"
|
96 |
+
str__ += f"\n\nMesh number of nodes: {nodes.shape[0]}\n"
|
97 |
+
if len(hf_dataset.description['in_fields_names'])>0:
|
98 |
+
str__ += "\ninput fields:\n"
|
99 |
+
for fname in hf_dataset.description['in_fields_names']:
|
100 |
+
str__ += f"- {fname}\n"
|
101 |
+
if len(hf_dataset.description['out_fields_names'])>0:
|
102 |
+
str__ += "\noutput fields:\n"
|
103 |
+
for fname in hf_dataset.description['out_fields_names']:
|
104 |
+
str__ += f"- {fname}\n"
|
105 |
|
106 |
return str__, color
|
107 |
|
|
|
109 |
if __name__ == "__main__":
|
110 |
|
111 |
with gr.Blocks() as demo:
|
112 |
+
gr.Markdown(_HEADER_)
|
113 |
+
with gr.Row(variant="panel"):
|
114 |
+
with gr.Column():
|
115 |
+
d1 = gr.Slider(0, nb_samples-1, value=0, label="Training sample id", info="Choose between 0 and "+str(nb_samples-1))
|
116 |
+
output1 = gr.Text(label="Training sample info")
|
117 |
+
with gr.Column():
|
118 |
+
d2 = gr.Dropdown(field_names_train, value=field_names_train[0], label="Field name")
|
119 |
+
output2 = gr.Image(label="Training sample visualization")
|
120 |
+
|
121 |
d1.input(sample_info, [d1, d2], [output1, output2])
|
122 |
d2.input(sample_info, [d1, d2], [output1, output2])
|
123 |
|
|
|
124 |
demo.launch()
|
125 |
|