snajmark commited on
Commit
a5a9921
·
1 Parent(s): bed6220

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -24
app.py CHANGED
@@ -355,29 +355,6 @@ def write_logs(message, message_type="Prediction"):
355
  # {"name": message_type, "message": message, "time": str(datetime.now())}
356
  # )
357
  return
358
-
359
- def predict(x, request: gr.Request):
360
- """
361
- Predict the hardness and yield strength using the ML model. Input data is a dataframe
362
- """
363
- loaded_model = tf.keras.models.load_model("hardness_nn_graph_separate_elements.h5")
364
- print("summary is", loaded_model.summary())
365
- #x = x.replace("", 0)
366
- x = np.asarray(x).astype("float32")
367
- y = loaded_model.predict(x)
368
- y_hardness = y[0][0]
369
- y_ys = y[0][1]
370
- minimum_hardness, maximum_hardness = scaling_factors['PROPERTY: HV']
371
- minimum_ys, maximum_ys = scaling_factors['PROPERTY: YS (MPa)']
372
- print("Prediction is ", y)
373
- if request is not None: # Verify if request is not None (when building the app the first request is None)
374
- message = f"{request.username}_{request.client.host}"
375
- print("MESSAGE")
376
- print(message)
377
- res = write_logs(message)
378
- #interpret_fig = utils.interpret(x)
379
- return (round(y_hardness*(maximum_hardness-minimum_hardness)+minimum_hardness, 2), 12,
380
- round(y_ys*(maximum_ys-minimum_ys)+minimum_ys, 2), 12)
381
 
382
  def fit_outputs_constraints(X, antimicrobial_activity_target, request: gr.Request):
383
  reduction_target = 100 - int(antimicrobial_activity_target)
@@ -417,7 +394,7 @@ def predict_inverse(antimicrobial_activity_target, request: gr.Request):
417
  if column in one_hot_mapping:
418
  optimized_x.loc[0, column] = one_hot_mapping[column][int(optimized_x.loc[0, column])]
419
 
420
- return optimized_x
421
 
422
 
423
  example_inputs = [80]
 
355
  # {"name": message_type, "message": message, "time": str(datetime.now())}
356
  # )
357
  return
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358
 
359
  def fit_outputs_constraints(X, antimicrobial_activity_target, request: gr.Request):
360
  reduction_target = 100 - int(antimicrobial_activity_target)
 
394
  if column in one_hot_mapping:
395
  optimized_x.loc[0, column] = one_hot_mapping[column][int(optimized_x.loc[0, column])]
396
 
397
+ return optimized_x.transpose()
398
 
399
 
400
  example_inputs = [80]