fabiencasenave
commited on
Commit
•
878eb5c
1
Parent(s):
2495238
Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,9 @@ nb_samples = 500
|
|
24 |
|
25 |
field_names_train = ["sig11", "sig22", "sig12", "U1", "U2", "q"]
|
26 |
|
27 |
-
|
|
|
|
|
28 |
|
29 |
|
30 |
def sample_info(sample_id_str, fieldn):
|
@@ -82,7 +84,24 @@ def sample_info(sample_id_str, fieldn):
|
|
82 |
|
83 |
str__ = f"Training sample {sample_id_str}\n"
|
84 |
str__ += str(plaid_sample)+"\n"
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
return str__, color
|
88 |
|
@@ -90,17 +109,17 @@ def sample_info(sample_id_str, fieldn):
|
|
90 |
if __name__ == "__main__":
|
91 |
|
92 |
with gr.Blocks() as demo:
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
|
|
101 |
d1.input(sample_info, [d1, d2], [output1, output2])
|
102 |
d2.input(sample_info, [d1, d2], [output1, output2])
|
103 |
|
104 |
-
|
105 |
demo.launch()
|
106 |
|
|
|
24 |
|
25 |
field_names_train = ["sig11", "sig22", "sig12", "U1", "U2", "q"]
|
26 |
|
27 |
+
_HEADER_ = '''
|
28 |
+
<h2><b>Visualization demo of <a href='https://huggingface.co/datasets/PLAID-datasets/Tensile2d' target='_blank'><b>Tensile2d dataset</b></b></h2>
|
29 |
+
'''
|
30 |
|
31 |
|
32 |
def sample_info(sample_id_str, fieldn):
|
|
|
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 |
|