from joblib import load import gradio as gr MODEL_NAME = "" loaded_model = load("model.joblib") def prediction_function(*args): values_list = [] for arg in args: values_list.append(int(arg)) prediction_result = loaded_model.predict([values_list])[0] return f"Predicted value: {prediction_result}" def regression_inputs(): input_labels = loaded_model.input_feature_names inputs = [] for input_label in input_labels: value = gr.Textbox(label=input_label, type="text") inputs.append(value) return inputs def regression_output(): output_label = loaded_model.output_feature_name output = gr.Textbox(label=output_label, type="text") return output def create_interface(): interface = gr.Interface( fn=prediction_function, inputs=regression_inputs(), outputs=regression_output(), title=MODEL_NAME, ) interface.launch(debug=True) create_interface()