Update app.py
Browse files
app.py
CHANGED
@@ -1153,6 +1153,19 @@ class Network(object):
|
|
1153 |
# return idx, other_data_input, true_output, predicted_output
|
1154 |
return pandas.concat([fd, df_pred], axis=1), pandas.concat([fd, df_true], axis=1)
|
1155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1156 |
def synthesis(self, idx=None):
|
1157 |
print(idx)
|
1158 |
|
@@ -1251,9 +1264,13 @@ def geometry(index):
|
|
1251 |
values = value_net.get_geometry(index)
|
1252 |
return plotly_fig(values)
|
1253 |
|
1254 |
-
def simple_analysis(index):
|
1255 |
-
forward_net = Network("16forward_structure.json", "16forward_weights.h5")
|
1256 |
-
|
|
|
|
|
|
|
|
|
1257 |
|
1258 |
def simple_synthesis(index):
|
1259 |
inverse_net = Network("16inverse_structure.json", "16inverse_weights.h5")
|
@@ -1356,8 +1373,7 @@ with gradio.Blocks() as demo:
|
|
1356 |
num.change(fn=geometry, inputs=[num], outputs=[geo])
|
1357 |
|
1358 |
btn1.click(fn=randomize_analysis, inputs=[whence_commeth_geometry], outputs=[radio, length, height, width, diameter, num, geo])
|
1359 |
-
btn2.click(fn=simple_analysis, inputs=[num], outputs=[pred, true])
|
1360 |
-
|
1361 |
with gradio.Tab("Synthesis"):
|
1362 |
with gradio.Tab("Spectrum from Dataset"):
|
1363 |
|
|
|
1153 |
# return idx, other_data_input, true_output, predicted_output
|
1154 |
return pandas.concat([fd, df_pred], axis=1), pandas.concat([fd, df_true], axis=1)
|
1155 |
|
1156 |
+
|
1157 |
+
def analysis_from_geometry(self, geometry):
|
1158 |
+
# Get the outputs
|
1159 |
+
predicted_output = self.network.predict(geometry.flatten())
|
1160 |
+
predicted_output = predicted_output.reshape((3, self.F))
|
1161 |
+
|
1162 |
+
f = numpy.linspace(0.05, 2.0, 64)
|
1163 |
+
fd = pandas.DataFrame(f).rename(columns={0: "Frequency"})
|
1164 |
+
df_pred = pandas.DataFrame(predicted_output.transpose()).rename(columns={0: "Surge", 1: "Heave", 2: "Pitch"})
|
1165 |
+
|
1166 |
+
return pandas.concat([fd, df_pred], axis=1), pandas.DataFrame()
|
1167 |
+
|
1168 |
+
|
1169 |
def synthesis(self, idx=None):
|
1170 |
print(idx)
|
1171 |
|
|
|
1264 |
values = value_net.get_geometry(index)
|
1265 |
return plotly_fig(values)
|
1266 |
|
1267 |
+
def simple_analysis(index, choice, shape, length, width, height, diameter):
|
1268 |
+
forward_net = Network("16forward_structure.json", "16forward_weights.h5")
|
1269 |
+
if choice == "Construct Shape from Parameters":
|
1270 |
+
return forward_net.analysis_from_geometry(make_voxels(shape, length, height, width, diameter))
|
1271 |
+
elif choice == "Pick Shape from Dataset":
|
1272 |
+
return forward_net.analysis(index)
|
1273 |
+
|
1274 |
|
1275 |
def simple_synthesis(index):
|
1276 |
inverse_net = Network("16inverse_structure.json", "16inverse_weights.h5")
|
|
|
1373 |
num.change(fn=geometry, inputs=[num], outputs=[geo])
|
1374 |
|
1375 |
btn1.click(fn=randomize_analysis, inputs=[whence_commeth_geometry], outputs=[radio, length, height, width, diameter, num, geo])
|
1376 |
+
btn2.click(fn=simple_analysis, inputs=[num, whence_commeth_geometry, radio, length, width, height, diameter], outputs=[pred, true])
|
|
|
1377 |
with gradio.Tab("Synthesis"):
|
1378 |
with gradio.Tab("Spectrum from Dataset"):
|
1379 |
|