|
import gradio as gr |
|
import joblib |
|
from PIL import Image |
|
|
|
|
|
best_model_cs = joblib.load("modelCS_V3.pkl") |
|
best_model_co2 = joblib.load("modelCO2_V3.pkl") |
|
|
|
|
|
def make_prediction(Fly_ash, GGBS_GGBFS, Fine_aggregate, Na2SiO3_solution, NaOH_solution, NaOH_concentration, Superplasticiser, Curing_temperature, Curing_Period, Testing_Age): |
|
predt_cs = best_model_cs.predict([[Fly_ash, GGBS_GGBFS, Fine_aggregate, Na2SiO3_solution, NaOH_solution, NaOH_concentration, Superplasticiser, Curing_temperature, Curing_Period, Testing_Age]]) |
|
predt_co2 = best_model_co2.predict([[Fly_ash, GGBS_GGBFS, Fine_aggregate, Na2SiO3_solution, NaOH_solution, NaOH_concentration, Superplasticiser, Curing_temperature, Curing_Period, Testing_Age]]) |
|
value_cs = round(predt_cs[0], 3) |
|
value_co2 = round(predt_co2[0], 3) |
|
image_component = gr.Image("MOO results_V3.png", label="multi-objective optimization", type="pil") |
|
return value_cs, value_co2, image_component, |
|
|
|
|
|
inputs = [ |
|
gr.Slider(20, 961.0, label='Fly ash (Kg/m³)', info="Amount of Fly ash (Kg/m³)"), |
|
gr.Slider(0, 711.0, label='GGBS or GGBFS (Kg/m³)', info="Amount of Ground Granulated Blast Furnace Slag(Kg/m³)"), |
|
gr.Slider(100, 1956.0, label='Fine aggregate (Kg/m³)', info="Amount of Fine aggregate (Kg/m³)"), |
|
gr.Slider(10, 531.0, label='Na₂SiO₃ solution (Kg/m³)', info="Amount of Sodium Silicate solution (Kg/m³)"), |
|
gr.Slider(10, 284.44, label='NaOH solution (Kg/m³)', info="Amount of Sodium Hydroxide solution (Kg/m³)"), |
|
gr.Slider(0, 16.0, label='NaOH concentration (M)', info="Sodium Hydroxide concentration (M)"), |
|
gr.Slider(0, 35.555, label='Superplasticiser (kg/m³)', info="Amount of Superplasticiser (kg/m³)"), |
|
gr.Slider(20, 120, label='Curing temperature (°C)'), |
|
gr.Slider(1, 90, label='Curing Period (days)', info="For curing temperature more than 30 °C the curing period should be maximum of 3 days"), |
|
gr.Slider(1, 180, label='Testing Age (days)', info="For curing temperature less than 30 °C the testing age should be equal to the curing period"), |
|
] |
|
|
|
|
|
|
|
outputs = [ |
|
gr.Textbox(label="Compressive strength (MPa)"), |
|
gr.Textbox(label="CO₂ footprint (Kg/m³)"), |
|
gr.Image(label="multi-objective optimization for geopolymer mortar"), |
|
] |
|
|
|
|
|
app = gr.Interface( |
|
fn=make_prediction, |
|
inputs=inputs, |
|
outputs=outputs, |
|
title="Alkali-Activated Mortar Compressive Strength Prediction Using Machine Learning with Multi-objective Optimization", |
|
description="Developed by Mohamed Rabieᵃ, Mohamed Aminᵇ, Usama Ebeadᵇ and Ibrahim Shaabanᵃ\n\nᵃUniversity of West London\n\nᵇQatar University \n\nContact: (mohamed.rabie@uwl.ac.uk ; mohamedrabie26@gmail.com)\n\nUse the sliders below to insert mix design quantity and click the submit button to make your prediction." |
|
) |
|
|
|
app.launch(share=False) |