snajmark commited on
Commit
081befc
·
1 Parent(s): 36cd12d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -104,7 +104,7 @@ def fit_outputs_constraints(x, hardness_target, ys_target, request: gr.Request):
104
  error_hardness, error_ys)
105
  return error_hardness + error_ys
106
 
107
- def predict_inverse(hardness_original_target, ys_original_target, request: gr.Request):
108
 
109
  one_hot_columns = utils.return_feature_names()
110
  min_df_hardness, max_df_hardness = scaling_factors["PROPERTY: HV"]
@@ -131,7 +131,7 @@ def predict_inverse(hardness_original_target, ys_original_target, request: gr.Re
131
 
132
  # Metals constraints
133
  metals_elements = [c for c in continuous_variables if c.startswith("PROPERTY: Metal")]
134
- metals_to_use = ['Al', 'Co', 'Fe', 'Cr']
135
  metals_to_use = ["PROPERTY: Metal " + metals_to_use[i] for i in range(len(metals_to_use))]
136
 
137
  # Domain
@@ -231,6 +231,13 @@ with gr.Blocks(css=css_styling, title=page_title, theme=osium_theme) as demo:
231
  gr.Markdown("### The target performance of your alloy")
232
  input_hardness = gr.Text(label="Enter your target hardness (in HV)")
233
  input_yield_strength = gr.Text(label="Enter your target yield strength (MPa)")
 
 
 
 
 
 
 
234
  with gr.Column():
235
  with gr.Row():
236
  #with gr.Column():
@@ -257,7 +264,7 @@ with gr.Blocks(css=css_styling, title=page_title, theme=osium_theme) as demo:
257
 
258
  prediction_button.click(
259
  fn=predict_inverse,
260
- inputs=[input_hardness, input_yield_strength],
261
  outputs=[optimal_parameters
262
  ],
263
  show_progress=True,
 
104
  error_hardness, error_ys)
105
  return error_hardness + error_ys
106
 
107
+ def predict_inverse(hardness_original_target, ys_original_target, metals_to_use, request: gr.Request):
108
 
109
  one_hot_columns = utils.return_feature_names()
110
  min_df_hardness, max_df_hardness = scaling_factors["PROPERTY: HV"]
 
131
 
132
  # Metals constraints
133
  metals_elements = [c for c in continuous_variables if c.startswith("PROPERTY: Metal")]
134
+ # metals_to_use = ['Al', 'Co', 'Fe', 'Cr']
135
  metals_to_use = ["PROPERTY: Metal " + metals_to_use[i] for i in range(len(metals_to_use))]
136
 
137
  # Domain
 
231
  gr.Markdown("### The target performance of your alloy")
232
  input_hardness = gr.Text(label="Enter your target hardness (in HV)")
233
  input_yield_strength = gr.Text(label="Enter your target yield strength (MPa)")
234
+ gr.Markdown('### Your metallic elements constraints')
235
+ metals_constraints = gr.CheckboxGroup(
236
+ choices=['Al', 'Co', 'Fe', 'Ni', 'Si', 'Cr', 'Nb', 'Ti',
237
+ 'Mn', 'V', 'Mo', 'Cu', 'Ta', 'Zr',
238
+ 'Hf', 'W', 'Zn', 'Sn', 'Re', 'C',
239
+ 'Pd', 'Sc', 'Y'], label="Your metals constraints",
240
+ )
241
  with gr.Column():
242
  with gr.Row():
243
  #with gr.Column():
 
264
 
265
  prediction_button.click(
266
  fn=predict_inverse,
267
+ inputs=[input_hardness, input_yield_strength, metals_constraints],
268
  outputs=[optimal_parameters
269
  ],
270
  show_progress=True,