Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,6 +22,39 @@ with gr.Blocks() as app:
|
|
| 22 |
inputs=[length, width, thickness],
|
| 23 |
outputs=[die_output, visualization_output],
|
| 24 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
with gr.Tab("Stress Analysis"):
|
| 27 |
gr.Markdown("### Select Simulation Tool and Enter Parameters for Stress Analysis")
|
|
|
|
| 22 |
inputs=[length, width, thickness],
|
| 23 |
outputs=[die_output, visualization_output],
|
| 24 |
)
|
| 25 |
+
import gradio as gr
|
| 26 |
+
from design import generate_die, visualize_die
|
| 27 |
+
|
| 28 |
+
# Gradio UI for Progressive Die Design
|
| 29 |
+
with gr.Blocks() as app:
|
| 30 |
+
gr.Markdown("## Progressive Die Designer")
|
| 31 |
+
|
| 32 |
+
# User input fields for die dimensions
|
| 33 |
+
length = gr.Number(label="Length (mm)", value=100)
|
| 34 |
+
width = gr.Number(label="Width (mm)", value=50)
|
| 35 |
+
thickness = gr.Number(label="Thickness (mm)", value=10)
|
| 36 |
+
|
| 37 |
+
# Outputs: STEP file location and 3D visualization image
|
| 38 |
+
die_output = gr.Textbox(label="STEP File Location")
|
| 39 |
+
visualization_output = gr.Image(label="3D Visualization")
|
| 40 |
+
|
| 41 |
+
# Button to generate die and visualization
|
| 42 |
+
die_button = gr.Button("Generate Die")
|
| 43 |
+
|
| 44 |
+
# Connect the button to both functions
|
| 45 |
+
def generate_outputs(l, w, t):
|
| 46 |
+
step_file = generate_die(l, w, t)
|
| 47 |
+
visualization_file = visualize_die(l, w, t)
|
| 48 |
+
return step_file, visualization_file
|
| 49 |
+
|
| 50 |
+
die_button.click(
|
| 51 |
+
generate_outputs,
|
| 52 |
+
inputs=[length, width, thickness],
|
| 53 |
+
outputs=[die_output, visualization_output],
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
# Launch the app
|
| 57 |
+
app.launch()
|
| 58 |
|
| 59 |
with gr.Tab("Stress Analysis"):
|
| 60 |
gr.Markdown("### Select Simulation Tool and Enter Parameters for Stress Analysis")
|