jithenderchoudary commited on
Commit
11ff458
·
verified ·
1 Parent(s): 5d0447a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -27
app.py CHANGED
@@ -2,43 +2,43 @@ import streamlit as st
2
  import joblib
3
  from models.optimizer import optimize_design
4
 
5
- # Correct usage of the 'with' statement
6
  with st.sidebar:
7
  tool_width = st.number_input("Tool Width (mm)", value=50)
8
  tool_height = st.number_input("Tool Height (mm)", value=20)
9
 
10
- # Additional code outside the 'with' block
11
  st.write(f"Tool dimensions: {tool_width}mm x {tool_height}mm")
12
 
13
  # Load pre-trained model
14
  model = joblib.load('models/defect_model.pkl')
 
 
15
  st.title("AI-Driven Press Tool Defect Predictor & Optimizer")
16
- # Input Form
17
- import streamlit as st
18
 
19
- # Example of a correct 'with' statement usage
20
- with st.sidebar:
21
- tool_width = st.number_input("Tool Width (mm)", value=50) # Indented properly
22
- tool_height = st.number_input("Tool Height (mm)", value=20) # Also indented properly
 
 
 
23
 
24
- # Code outside the 'with' block
25
- st.write(f"Tool dimensions: {tool_width}mm x {tool_height}mm")
26
 
27
- with st.form("Input Parameters"):
28
- tool_width = st.number_input("Tool Width (mm)", value=50)
29
- tool_height = st.number_input("Tool Height (mm)", value=20)
30
- material_strength = st.number_input("Material Strength (MPa)", value=300)
31
- press_force = st.number_input("Press Force (kN)", value=100)
32
- submit = st.form_submit_button("Predict & Optimize")
33
  if submit:
34
- # Predict defect
35
- input_data = [[tool_width, tool_height, material_strength, press_force]]
36
- defect = model.predict(input_data)[0]
37
- st.subheader("Predicted Defect")
38
- st.write(f"Predicted Defect Type: **{defect}**")
39
- # Optimize design
40
- optimized_params = optimize_design(tool_width, tool_height, material_strength,
41
- press_force)
42
- st.subheader("Optimized Design Parameters")
43
- st.write(optimized_params)
44
- st.success("Optimization and Prediction Complete!")
 
 
 
2
  import joblib
3
  from models.optimizer import optimize_design
4
 
5
+ # Sidebar for user inputs
6
  with st.sidebar:
7
  tool_width = st.number_input("Tool Width (mm)", value=50)
8
  tool_height = st.number_input("Tool Height (mm)", value=20)
9
 
10
+ # Display tool dimensions
11
  st.write(f"Tool dimensions: {tool_width}mm x {tool_height}mm")
12
 
13
  # Load pre-trained model
14
  model = joblib.load('models/defect_model.pkl')
15
+
16
+ # Title
17
  st.title("AI-Driven Press Tool Defect Predictor & Optimizer")
 
 
18
 
19
+ # Input Form
20
+ with st.form("Input Parameters"):
21
+ # Form input fields
22
+ tool_width = st.number_input("Tool Width (mm)", value=50)
23
+ tool_height = st.number_input("Tool Height (mm)", value=20)
24
+ material_strength = st.number_input("Material Strength (MPa)", value=300)
25
+ press_force = st.number_input("Press Force (kN)", value=100)
26
 
27
+ # Submit button
28
+ submit = st.form_submit_button("Predict & Optimize")
29
 
30
+ # Handle form submission
 
 
 
 
 
31
  if submit:
32
+ # Predict defect
33
+ input_data = [[tool_width, tool_height, material_strength, press_force]]
34
+ defect = model.predict(input_data)[0]
35
+ st.subheader("Predicted Defect")
36
+ st.write(f"Predicted Defect Type: **{defect}**")
37
+
38
+ # Optimize design
39
+ optimized_params = optimize_design(tool_width, tool_height, material_strength, press_force)
40
+ st.subheader("Optimized Design Parameters")
41
+ st.write(optimized_params)
42
+
43
+ # Completion message
44
+ st.success("Optimization and Prediction Complete!")