Spaces:
Runtime error
Runtime error
Generate and display endpoints
Browse files
app.py
CHANGED
|
@@ -242,9 +242,10 @@ density_options = ["{:.2f}".format(x) for x in numpy.linspace(0.1, 1, 10)]
|
|
| 242 |
thickness_options = [str(int(x)) for x in numpy.linspace(0, 10, 11)]
|
| 243 |
interpolation_options = [str(int(x)) for x in [3, 5, 10, 20]]
|
| 244 |
|
|
|
|
| 245 |
def interpolate(t1, t2, d1, d2, th1, th2, steps):
|
|
|
|
| 246 |
decoder_model_boxes = tensorflow.keras.models.load_model('data/decoder_model_boxes', compile=False)
|
| 247 |
-
# # compile=False ignores a warning from tensorflow, can be removed to see warning
|
| 248 |
|
| 249 |
# # import the encoder model architecture
|
| 250 |
json_file_loaded = open('data/model.json', 'r')
|
|
@@ -293,16 +294,32 @@ def interpolate(t1, t2, d1, d2, th1, th2, steps):
|
|
| 293 |
|
| 294 |
return transition_region
|
| 295 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
with gradio.Blocks() as demo:
|
| 297 |
with gradio.Row():
|
| 298 |
with gradio.Column():
|
| 299 |
t1 = gradio.Dropdown(endpoint_types, label="Type 1", value=random.choice(endpoint_types))
|
| 300 |
d1 = gradio.Dropdown(density_options, label="Density 1", value=random.choice(density_options))
|
| 301 |
th1 = gradio.Dropdown(thickness_options, label="Thickness 1", value=random.choice(thickness_options))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
with gradio.Column():
|
| 303 |
t2 = gradio.Dropdown(endpoint_types, label="Type 2", value=random.choice(endpoint_types))
|
| 304 |
d2 = gradio.Dropdown(density_options, label="Density 2", value=random.choice(density_options))
|
| 305 |
th2 = gradio.Dropdown(thickness_options, label="Thickness 2", value=random.choice(thickness_options))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
steps = gradio.Dropdown(interpolation_options, label="Interpolation Length", value=random.choice(interpolation_options))
|
| 307 |
btn = gradio.Button("Run")
|
| 308 |
img = gradio.Image(label="Transition")
|
|
|
|
| 242 |
thickness_options = [str(int(x)) for x in numpy.linspace(0, 10, 11)]
|
| 243 |
interpolation_options = [str(int(x)) for x in [3, 5, 10, 20]]
|
| 244 |
|
| 245 |
+
|
| 246 |
def interpolate(t1, t2, d1, d2, th1, th2, steps):
|
| 247 |
+
# Load the decoder model
|
| 248 |
decoder_model_boxes = tensorflow.keras.models.load_model('data/decoder_model_boxes', compile=False)
|
|
|
|
| 249 |
|
| 250 |
# # import the encoder model architecture
|
| 251 |
json_file_loaded = open('data/model.json', 'r')
|
|
|
|
| 294 |
|
| 295 |
return transition_region
|
| 296 |
|
| 297 |
+
def generate_unit_cell(t, d, th):
|
| 298 |
+
number_1 = globals()[t](int(th), float(d), 28)
|
| 299 |
+
|
| 300 |
+
# resize the array to match the prediction size requirement
|
| 301 |
+
number_1_expand = np.expand_dims(np.expand_dims(number_1, axis=2), axis=0)
|
| 302 |
+
|
| 303 |
+
return number_1_expand[0, :, :, 0]
|
| 304 |
+
|
| 305 |
with gradio.Blocks() as demo:
|
| 306 |
with gradio.Row():
|
| 307 |
with gradio.Column():
|
| 308 |
t1 = gradio.Dropdown(endpoint_types, label="Type 1", value=random.choice(endpoint_types))
|
| 309 |
d1 = gradio.Dropdown(density_options, label="Density 1", value=random.choice(density_options))
|
| 310 |
th1 = gradio.Dropdown(thickness_options, label="Thickness 1", value=random.choice(thickness_options))
|
| 311 |
+
img1 = gradio.Image(label="Endpoint 1")
|
| 312 |
+
t1.change(fn=generate_unit_cell, inputs=[t1, d1, th1], outputs=[img1])
|
| 313 |
+
d1.change(fn=generate_unit_cell, inputs=[t1, d1, th1], outputs=[img1])
|
| 314 |
+
th1.change(fn=generate_unit_cell, inputs=[t1, d1, th1], outputs=[img1])
|
| 315 |
with gradio.Column():
|
| 316 |
t2 = gradio.Dropdown(endpoint_types, label="Type 2", value=random.choice(endpoint_types))
|
| 317 |
d2 = gradio.Dropdown(density_options, label="Density 2", value=random.choice(density_options))
|
| 318 |
th2 = gradio.Dropdown(thickness_options, label="Thickness 2", value=random.choice(thickness_options))
|
| 319 |
+
img2 = gradio.Image(label="Endpoint 2")
|
| 320 |
+
t2.change(fn=generate_unit_cell, inputs=[t2, d2, th2], outputs=[img1])
|
| 321 |
+
d2.change(fn=generate_unit_cell, inputs=[t2, d2, th2], outputs=[img1])
|
| 322 |
+
th2.change(fn=generate_unit_cell, inputs=[t2, d2, th2], outputs=[img1])
|
| 323 |
steps = gradio.Dropdown(interpolation_options, label="Interpolation Length", value=random.choice(interpolation_options))
|
| 324 |
btn = gradio.Button("Run")
|
| 325 |
img = gradio.Image(label="Transition")
|