karthikmn commited on
Commit
595cd05
·
verified ·
1 Parent(s): 7b5d97a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py CHANGED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from ai_models import train_models, load_models
3
+ from ansys_simulation import run_ansys_simulation
4
+ from visualization import generate_graph
5
+
6
+ # Load AI models
7
+ stress_model, deformation_model, pass_fail_model = load_models()
8
+
9
+ def ai_and_simulation_workflow(thickness, hole_diameter, force):
10
+ # AI Pre-Screening
11
+ pre_screen = pass_fail_model.predict([[thickness, hole_diameter, force]])[0]
12
+ if pre_screen == 0:
13
+ return "AI predicts failure. Adjust parameters.", None
14
+
15
+ # ANSYS Simulation
16
+ max_stress, max_deformation = run_ansys_simulation(thickness, hole_diameter, force)
17
+
18
+ # Generate Visualization
19
+ graph_path = generate_graph(thickness, hole_diameter, force, max_stress, max_deformation)
20
+
21
+ return f"Pass: Stress={max_stress} Pa, Deformation={max_deformation} mm", graph_path
22
+
23
+ # Gradio UI
24
+ interface = gr.Interface(
25
+ fn=ai_and_simulation_workflow,
26
+ inputs=[
27
+ gr.Slider(10, 50, step=1, label="Thickness (mm)"),
28
+ gr.Slider(5, 25, step=1, label="Hole Diameter (mm)"),
29
+ gr.Slider(1000, 15000, step=500, label="Force (N)")
30
+ ],
31
+ outputs=[
32
+ gr.Textbox(label="Simulation Status"),
33
+ gr.Image(label="Dynamic Results Visualization")
34
+ ],
35
+ title="AI-Driven ANSYS Design Validator",
36
+ description="Dynamic tool for optimizing and validating press tool designs.",
37
+ theme="default",
38
+ live=True
39
+ )
40
+
41
+ if __name__ == "__main__":
42
+ interface.launch()