Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,7 @@ import platform
|
|
11 |
import scipy.spatial
|
12 |
import plotly.graph_objects as go
|
13 |
import random
|
|
|
14 |
|
15 |
# Disable eager execution because its bad
|
16 |
from tensorflow.python.framework.ops import disable_eager_execution
|
@@ -1099,7 +1100,7 @@ curves, geometry, S, N, D, F, G, new_curves, new_geometry = load_data()
|
|
1099 |
|
1100 |
class Network(object):
|
1101 |
|
1102 |
-
def __init__(self,
|
1103 |
# Instantiate variables
|
1104 |
# self.curves = curves
|
1105 |
# self.new_curves = new_curves
|
@@ -1112,9 +1113,10 @@ class Network(object):
|
|
1112 |
# self.G = G
|
1113 |
|
1114 |
# Load network
|
1115 |
-
with open(structure, 'r') as file:
|
1116 |
-
|
1117 |
-
|
|
|
1118 |
|
1119 |
def analysis(self, idx=None):
|
1120 |
print(idx)
|
@@ -1240,7 +1242,8 @@ def plotly_fig(values):
|
|
1240 |
))
|
1241 |
return fig
|
1242 |
|
1243 |
-
|
|
|
1244 |
|
1245 |
def performance(index):
|
1246 |
return value_net.get_performance(index)
|
@@ -1250,7 +1253,8 @@ def geometry(index):
|
|
1250 |
return plotly_fig(values)
|
1251 |
|
1252 |
def simple_analysis(index, choice, shape, length, width, height, diameter):
|
1253 |
-
forward_net = Network("
|
|
|
1254 |
if choice == "Construct Shape from Parameters":
|
1255 |
return forward_net.analysis_from_geometry(make_voxels_without_figure(shape, length, height, width, diameter))
|
1256 |
elif choice == "Pick Shape from Dataset":
|
@@ -1258,16 +1262,17 @@ def simple_analysis(index, choice, shape, length, width, height, diameter):
|
|
1258 |
|
1259 |
|
1260 |
def simple_synthesis(index):
|
1261 |
-
inverse_net = Network("
|
|
|
1262 |
pred, true = inverse_net.synthesis(index)
|
1263 |
return plotly_fig(pred), plotly_fig(true)
|
1264 |
|
1265 |
def synthesis_from_spectrum(df):
|
1266 |
-
inverse_net = Network("
|
|
|
1267 |
pred = inverse_net.synthesis_from_spectrum(df.to_numpy()[:, 1:])
|
1268 |
return plotly_fig(pred)
|
1269 |
|
1270 |
-
|
1271 |
|
1272 |
|
1273 |
def change_textbox(choice, length, height, width, diameter):
|
|
|
11 |
import scipy.spatial
|
12 |
import plotly.graph_objects as go
|
13 |
import random
|
14 |
+
from huggingface_hub import from_pretrained_keras
|
15 |
|
16 |
# Disable eager execution because its bad
|
17 |
from tensorflow.python.framework.ops import disable_eager_execution
|
|
|
1100 |
|
1101 |
class Network(object):
|
1102 |
|
1103 |
+
def __init__(self, type):
|
1104 |
# Instantiate variables
|
1105 |
# self.curves = curves
|
1106 |
# self.new_curves = new_curves
|
|
|
1113 |
# self.G = G
|
1114 |
|
1115 |
# Load network
|
1116 |
+
# with open(structure, 'r') as file:
|
1117 |
+
# self.network = keras.models.model_from_json(file.read())
|
1118 |
+
# self.network.load_weights(weights)
|
1119 |
+
self.network = from_pretrained_keras("cmudrc/wave-energy-analysis") if type == "forward" else from_pretrained_keras("cmudrc/wave-energy-synthesis")
|
1120 |
|
1121 |
def analysis(self, idx=None):
|
1122 |
print(idx)
|
|
|
1242 |
))
|
1243 |
return fig
|
1244 |
|
1245 |
+
|
1246 |
+
value_net = Network("forward")
|
1247 |
|
1248 |
def performance(index):
|
1249 |
return value_net.get_performance(index)
|
|
|
1253 |
return plotly_fig(values)
|
1254 |
|
1255 |
def simple_analysis(index, choice, shape, length, width, height, diameter):
|
1256 |
+
forward_net = Network("forward")
|
1257 |
+
# forward_net = Network("16forward_structure.json", "16forward_weights.h5")
|
1258 |
if choice == "Construct Shape from Parameters":
|
1259 |
return forward_net.analysis_from_geometry(make_voxels_without_figure(shape, length, height, width, diameter))
|
1260 |
elif choice == "Pick Shape from Dataset":
|
|
|
1262 |
|
1263 |
|
1264 |
def simple_synthesis(index):
|
1265 |
+
inverse_net = Network("inverse")
|
1266 |
+
# inverse_net = Network("16inverse_structure.json", "16inverse_weights.h5")
|
1267 |
pred, true = inverse_net.synthesis(index)
|
1268 |
return plotly_fig(pred), plotly_fig(true)
|
1269 |
|
1270 |
def synthesis_from_spectrum(df):
|
1271 |
+
inverse_net = Network("inverse")
|
1272 |
+
# inverse_net = Network("16inverse_structure.json", "16inverse_weights.h5")
|
1273 |
pred = inverse_net.synthesis_from_spectrum(df.to_numpy()[:, 1:])
|
1274 |
return plotly_fig(pred)
|
1275 |
|
|
|
1276 |
|
1277 |
|
1278 |
def change_textbox(choice, length, height, width, diameter):
|