ccm commited on
Commit
0455569
·
1 Parent(s): dc2d342

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -1283,11 +1283,11 @@ def change_textbox(choice, length, height, width, diameter):
1283
 
1284
  import random
1285
 
1286
- def geometry_change(choice):
1287
- if choice == "Construct Shape from Parameters":
1288
- return [gradio.Radio.update(visible=True), gradio.Slider.update(visible=True), gradio.Slider.update(visible=True), gradio.Slider.update(visible=True), gradio.Slider.update(visible=True), gradio.Number.update(visible=False), gradio.Timeseries.update(visible=False)]
1289
  elif choice == "Pick Shape from Dataset":
1290
- return [gradio.Radio.update(visible=False), gradio.Slider.update(visible=False), gradio.Slider.update(visible=False), gradio.Slider.update(visible=False), gradio.Slider.update(visible=False), gradio.Number.update(visible=True), gradio.Timeseries.update(visible=True)]
1291
 
1292
  with gradio.Blocks() as demo:
1293
  with gradio.Accordion("✨ Read about the ML model here! ✨", open=False):
@@ -1307,19 +1307,19 @@ with gradio.Blocks() as demo:
1307
  ["Construct Shape from Parameters", "Pick Shape from Dataset"], label="How would you like to generate the shape of the offshore structure for analysis?", value="Construct Shape from Parameters"
1308
  )
1309
  radio = gradio.Radio(
1310
- ["box", "cone", "cylinder", "sphere", "wedge"], label="What kind of shape would you like to generate?", value="box"
1311
  )
1312
- height = gradio.Slider(label="Height", interactive=True, minimum=3.0, maximum=10.0, value=6.5)
1313
- width = gradio.Slider(label="Width", interactive=True, minimum=3.0, maximum=10.0, value=6.5)
1314
- diameter = gradio.Slider(label="Diameter", interactive=True, minimum=3.0, maximum=10.0, value=6.5, visible=False)
1315
- length = gradio.Slider(label="Length", interactive=True, minimum=3.0, maximum=10.0, value=6.5)
1316
 
1317
 
1318
  num = gradio.Number(42, label="Type the index of the shape you would like to use or randomly select it.", visible=False)
1319
 
1320
  btn1 = gradio.Button("Randomize")
1321
  with gradio.Column():
1322
- geo = gradio.Plot(label="Geometry")
1323
 
1324
 
1325
  with gradio.Row():
@@ -1333,7 +1333,7 @@ with gradio.Blocks() as demo:
1333
  true = gradio.Timeseries(x="Frequency", y=['Surge', 'Heave', 'Pitch'], label="True")
1334
 
1335
  radio.change(fn=change_textbox, inputs=[radio, length, height, width, diameter], outputs=[height, width, diameter, length, geo])
1336
- whence_commeth_geometry.change(fn=geometry_change, inputs=[whence_commeth_geometry], outputs=[radio, height, width, diameter, length, num, true])
1337
  num.change(fn=geometry, inputs=[num], outputs=[geo])
1338
 
1339
  btn1.click(fn=lambda: random.randint(1, 4999), inputs=[], outputs=[num])
 
1283
 
1284
  import random
1285
 
1286
+ def geometry_change(choice, choice2, num, length, width, height, diameter):
1287
+ if choice == "Construct Shape from Parameters":
1288
+ return [gradio.Radio.update(visible=True), gradio.Slider.update(visible=True), gradio.Slider.update(visible=True), gradio.Slider.update(visible=True), gradio.Slider.update(visible=True), gradio.Number.update(visible=False), gradio.Timeseries.update(visible=False), gradio.Plot.update(make_voxels(choice2, length, height, width, diameter)]
1289
  elif choice == "Pick Shape from Dataset":
1290
+ return [gradio.Radio.update(visible=False), gradio.Slider.update(visible=False), gradio.Slider.update(visible=False), gradio.Slider.update(visible=False), gradio.Slider.update(visible=False), gradio.Number.update(visible=True), gradio.Timeseries.update(visible=True), gradio.Plot.update(geometry(num))]
1291
 
1292
  with gradio.Blocks() as demo:
1293
  with gradio.Accordion("✨ Read about the ML model here! ✨", open=False):
 
1307
  ["Construct Shape from Parameters", "Pick Shape from Dataset"], label="How would you like to generate the shape of the offshore structure for analysis?", value="Construct Shape from Parameters"
1308
  )
1309
  radio = gradio.Radio(
1310
+ ["box", "cone", "cylinder", "sphere", "wedge"], label="What kind of shape would you like to generate?", value="sphere"
1311
  )
1312
+ height = gradio.Slider(label="Height", interactive=True, minimum=3.0, maximum=10.0, value=6.5, visible=False)
1313
+ width = gradio.Slider(label="Width", interactive=True, minimum=3.0, maximum=10.0, value=6.5, visible=False)
1314
+ diameter = gradio.Slider(label="Diameter", interactive=True, minimum=3.0, maximum=10.0, value=6.5, visible=True)
1315
+ length = gradio.Slider(label="Length", interactive=True, minimum=3.0, maximum=10.0, value=6.5, visible=False)
1316
 
1317
 
1318
  num = gradio.Number(42, label="Type the index of the shape you would like to use or randomly select it.", visible=False)
1319
 
1320
  btn1 = gradio.Button("Randomize")
1321
  with gradio.Column():
1322
+ geo = gradio.Plot(make_voxels("sphere", 6.5, 6.5, 6.5, 6.5), label="Geometry")
1323
 
1324
 
1325
  with gradio.Row():
 
1333
  true = gradio.Timeseries(x="Frequency", y=['Surge', 'Heave', 'Pitch'], label="True")
1334
 
1335
  radio.change(fn=change_textbox, inputs=[radio, length, height, width, diameter], outputs=[height, width, diameter, length, geo])
1336
+ whence_commeth_geometry.change(fn=geometry_change, inputs=[whence_commeth_geometry, radio, num, length, height, width, diameter], outputs=[radio, height, width, diameter, length, num, true, geo])
1337
  num.change(fn=geometry, inputs=[num], outputs=[geo])
1338
 
1339
  btn1.click(fn=lambda: random.randint(1, 4999), inputs=[], outputs=[num])