File size: 1,080 Bytes
e199a22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import sklearn
import gradio as gr
import joblib
import pandas as pd

pipe = joblib.load("./model.pkl")

title = "Supersoaker Defective Product Prediction"
description = "This model predicts Supersoaker production line failures. The examples as of now are not parsed correctly, soon to be fixed. "


with open("./config.json") as f:
    config_dict = eval(f.read())
headers = config_dict["sklearn"]["columns"]

example_dict = config_dict["sklearn"]["example_input"]
df = pd.DataFrame.from_dict(example_dict,orient='index').transpose()
examples=df.to_numpy().tolist()
final_examples = [[[example]] for example in examples]

inputs = gr.Dataframe(headers = [item for item in example_dict])
outputs = gr.Dataframe(headers = ["results"])


def infer(inputs):
    data = pd.DataFrame(inputs, columns=[item for item in example_dict])
    predictions = pipe.predict(inputs)
    return pd.DataFrame(predictions, columns=["results"])

gr.Interface(infer, inputs = inputs, outputs = outputs, title = title,
            description = description, examples=final_examples).launch(debug=True)