Concrete123 commited on
Commit
831127d
·
verified ·
1 Parent(s): 14f1cde

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -26
app.py CHANGED
@@ -36,34 +36,19 @@ clf.fit(x_train, y_train)
36
 
37
 
38
  import gradio as gr
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
  def OPS_LWAC(OPC, SCM_FA, SCM_SF, w_b, FA, CA, OPS, SP, T):
48
  # Turning the arguments into a numpy array
49
  x = np.array([OPC, SCM_FA, SCM_SF, w_b, FA, CA, OPS, SP, T])
50
  prediction = clf.pred_dist(x.reshape(1, -1))
51
  aa=prediction.params["loc"].item()
 
52
  bb=prediction.params["scale"].item()
53
-
54
- # Plotting probability density curve
55
- x_values = np.linspace(aa - 3*bb, aa + 3*bb, 1000)
56
- y_values = norm.pdf(x_values, aa, bb)
57
- plt.plot(x_values, y_values, label='Probability Density Curve')
58
- plt.xlabel('Strength (MPa)')
59
- plt.ylabel('Probability Density')
60
- plt.title('Probability Density Curve for Compressive Strength')
61
- plt.grid(True)
62
- plt.legend()
63
- plt.savefig('probability_density_curve.png')
64
-
65
- result_string = "[CS: {:.2f}; σ: {:.2f}]".format(aa, bb)
66
- return result_string, "probability_density_curve.png"
67
 
68
  inputs = [
69
  gr.inputs.Number(label="cement content (OPC, unit: kg/m3)"),
@@ -76,10 +61,7 @@ inputs = [
76
  gr.inputs.Number(label="superplasticizer content (SP, unit: kg/m3)"),
77
  gr.inputs.Number(label="curing time (T, unit: d)")
78
  ]
79
- outputs = [
80
- gr.outputs.Textbox(label="Estimated mean prediction and σ value (unit: MPa)"),
81
- gr.outputs.Image(label="Probability Density Curve")
82
- ]
83
 
84
  app = gr.Interface(fn=OPS_LWAC, inputs=inputs, outputs=outputs, description="Estimation of compressive strength of OPS-based lightweight concrete")
85
  app.launch()
 
36
 
37
 
38
  import gradio as gr
 
 
 
 
 
 
 
 
39
  def OPS_LWAC(OPC, SCM_FA, SCM_SF, w_b, FA, CA, OPS, SP, T):
40
  # Turning the arguments into a numpy array
41
  x = np.array([OPC, SCM_FA, SCM_SF, w_b, FA, CA, OPS, SP, T])
42
  prediction = clf.pred_dist(x.reshape(1, -1))
43
  aa=prediction.params["loc"].item()
44
+ #value1 = aa[0]
45
  bb=prediction.params["scale"].item()
46
+ #value2 = bb[0]
47
+ #prediction = clf.predict(x.reshape(1, -1))
48
+ #-3*y_dists.params["scale"]+y_dists.params["loc"]
49
+ result_string = "[CS: {:.3f}; σ: {:.3f}]".format(aa, bb)
50
+ return result_string
51
+ #return [aa, bb]
 
 
 
 
 
 
 
 
52
 
53
  inputs = [
54
  gr.inputs.Number(label="cement content (OPC, unit: kg/m3)"),
 
61
  gr.inputs.Number(label="superplasticizer content (SP, unit: kg/m3)"),
62
  gr.inputs.Number(label="curing time (T, unit: d)")
63
  ]
64
+ outputs = gr.outputs.Textbox(label="Estimated mean prediction and σ value (unit: MPa)")
 
 
 
65
 
66
  app = gr.Interface(fn=OPS_LWAC, inputs=inputs, outputs=outputs, description="Estimation of compressive strength of OPS-based lightweight concrete")
67
  app.launch()