Update app.py
Browse files
app.py
CHANGED
|
@@ -118,6 +118,18 @@ class Network(object):
|
|
| 118 |
|
| 119 |
# return idx, other_data_input, true_output, predicted_output
|
| 120 |
return predicted_output, true_output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
def get_geometry(self, idx=None):
|
| 123 |
|
|
@@ -235,9 +247,26 @@ with gradio.Blocks() as synthesis_demo:
|
|
| 235 |
btn1.click(fn=performance, inputs=[num], outputs=[perf])
|
| 236 |
btn2.click(fn=simple_synthesis, inputs=[num], outputs=[pred, true])
|
| 237 |
|
| 238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
|
| 240 |
-
all_analysis_demos = gradio.TabbedInterface([analysis_demo], ["
|
| 241 |
|
| 242 |
demo = gradio.TabbedInterface([all_analysis_demos, all_synthesis_demos], ["Analysis", "Synthesis"])
|
| 243 |
demo.launch()
|
|
|
|
| 118 |
|
| 119 |
# return idx, other_data_input, true_output, predicted_output
|
| 120 |
return predicted_output, true_output
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def synthesis_from_spectrum(self, other_data_input):
|
| 124 |
+
# Get the input
|
| 125 |
+
data_input = other_data_input.reshape((1, 3*self.F))
|
| 126 |
+
|
| 127 |
+
# Get the outputs
|
| 128 |
+
predicted_output = self.network.predict(data_input)
|
| 129 |
+
predicted_output = predicted_output.reshape((self.G, self.G, self.G), order='F')
|
| 130 |
+
|
| 131 |
+
# return idx, other_data_input, true_output, predicted_output
|
| 132 |
+
return true_output
|
| 133 |
|
| 134 |
def get_geometry(self, idx=None):
|
| 135 |
|
|
|
|
| 247 |
btn1.click(fn=performance, inputs=[num], outputs=[perf])
|
| 248 |
btn2.click(fn=simple_synthesis, inputs=[num], outputs=[pred, true])
|
| 249 |
|
| 250 |
+
|
| 251 |
+
with gradio.Blocks() as synthesis_demo2:
|
| 252 |
+
with gradio.Row():
|
| 253 |
+
perf = gradio.Timeseries(x="Frequency", y=['Surge', 'Heave', 'Pitch'], label="Performance")
|
| 254 |
+
|
| 255 |
+
with gradio.Row():
|
| 256 |
+
btn2 = gradio.Button("Synthesize Geometry")
|
| 257 |
+
|
| 258 |
+
with gradio.Row():
|
| 259 |
+
with gradio.Column():
|
| 260 |
+
pred = gradio.Plot(label="Predicted")
|
| 261 |
+
|
| 262 |
+
with gradio.Column():
|
| 263 |
+
true = gradio.Plot(label="True")
|
| 264 |
+
|
| 265 |
+
btn2.click(fn=synthesis_from_spectrum, inputs=[num], outputs=[pred, true])
|
| 266 |
+
|
| 267 |
+
all_synthesis_demos = gradio.TabbedInterface([synthesis_demo, synthesis_demo2], ["Spectrum from Data", "Spectrum from File"])
|
| 268 |
|
| 269 |
+
all_analysis_demos = gradio.TabbedInterface([analysis_demo], ["Geometry from Data"])
|
| 270 |
|
| 271 |
demo = gradio.TabbedInterface([all_analysis_demos, all_synthesis_demos], ["Analysis", "Synthesis"])
|
| 272 |
demo.launch()
|