Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,124 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from ai
|
| 3 |
-
_
|
| 4 |
-
models import train
|
| 5 |
-
_
|
| 6 |
-
models, load
|
| 7 |
-
_
|
| 8 |
-
models
|
| 9 |
-
from ansys
|
| 10 |
-
_
|
| 11 |
-
simulation import run
|
| 12 |
-
_
|
| 13 |
-
ansys
|
| 14 |
-
_
|
| 15 |
-
from visualization import generate
|
| 16 |
-
_graph
|
| 17 |
-
simulation
|
| 18 |
-
# Load AI models
|
| 19 |
-
stress
|
| 20 |
-
_
|
| 21 |
-
model, deformation
|
| 22 |
-
_
|
| 23 |
-
model, pass
|
| 24 |
-
fail
|
| 25 |
-
model = load
|
| 26 |
-
_
|
| 27 |
-
_
|
| 28 |
-
_
|
| 29 |
-
models()
|
| 30 |
-
def ai
|
| 31 |
-
and
|
| 32 |
-
simulation
|
| 33 |
-
_
|
| 34 |
-
_
|
| 35 |
-
_
|
| 36 |
-
workflow(thickness, hole
|
| 37 |
-
_
|
| 38 |
-
diameter, force):
|
| 39 |
-
# AI Pre-Screening
|
| 40 |
-
pre
|
| 41 |
-
_
|
| 42 |
-
screen = pass
|
| 43 |
-
fail
|
| 44 |
-
_
|
| 45 |
-
_
|
| 46 |
-
model.predict([[thickness, hole
|
| 47 |
-
_
|
| 48 |
-
diameter, force]])[0]
|
| 49 |
-
if pre
|
| 50 |
-
screen == 0:
|
| 51 |
-
_
|
| 52 |
-
return "AI predicts failure. Adjust parameters.
|
| 53 |
-
"
|
| 54 |
-
, None
|
| 55 |
-
15/74
|
| 56 |
-
# ANSYS Simulation
|
| 57 |
-
max
|
| 58 |
-
_
|
| 59 |
-
stress, max
|
| 60 |
-
deformation = run
|
| 61 |
-
_
|
| 62 |
-
_
|
| 63 |
-
ansys
|
| 64 |
-
_
|
| 65 |
-
simulation(thickness, hole
|
| 66 |
-
_
|
| 67 |
-
diameter,
|
| 68 |
-
force)
|
| 69 |
-
# Generate Visualization
|
| 70 |
-
graph
|
| 71 |
-
_path = generate
|
| 72 |
-
_graph(thickness, hole
|
| 73 |
-
_
|
| 74 |
-
diameter, force, max
|
| 75 |
-
_
|
| 76 |
-
max
|
| 77 |
-
_
|
| 78 |
-
deformation)
|
| 79 |
-
stress,
|
| 80 |
-
return f"Pass: Stress={max
|
| 81 |
-
_
|
| 82 |
-
stress} Pa, Deformation={max
|
| 83 |
-
_
|
| 84 |
-
deformation} mm"
|
| 85 |
-
graph
|
| 86 |
-
_path
|
| 87 |
-
,
|
| 88 |
-
# Gradio UI
|
| 89 |
-
interface = gr.Interface(
|
| 90 |
-
fn=ai
|
| 91 |
-
and
|
| 92 |
-
simulation
|
| 93 |
-
_
|
| 94 |
-
_
|
| 95 |
-
_
|
| 96 |
-
workflow,
|
| 97 |
-
inputs=[
|
| 98 |
-
gr.Slider(10, 50, step=1, label="Thickness (mm)"),
|
| 99 |
-
gr.Slider(5, 25, step=1, label="Hole Diameter (mm)"),
|
| 100 |
-
gr.Slider(1000, 15000, step=500, label="Force (N)")
|
| 101 |
-
],
|
| 102 |
-
outputs=[
|
| 103 |
-
gr.Textbox(label="Simulation Status"),
|
| 104 |
-
gr.Image(label="Dynamic Results Visualization")
|
| 105 |
-
],
|
| 106 |
-
title="AI-Driven ANSYS Design Validator"
|
| 107 |
-
,
|
| 108 |
-
description="Dynamic tool for optimizing and validating press tool designs.
|
| 109 |
-
theme="default"
|
| 110 |
-
,
|
| 111 |
-
live=True
|
| 112 |
-
"
|
| 113 |
-
,
|
| 114 |
-
)
|
| 115 |
-
if
|
| 116 |
-
name
|
| 117 |
-
== "
|
| 118 |
-
main
|
| 119 |
-
":
|
| 120 |
-
__
|
| 121 |
-
__
|
| 122 |
-
__
|
| 123 |
-
__
|
| 124 |
-
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|