File size: 971 Bytes
b3d4fe7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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()