abidlabs HF Staff commited on
Commit
e199a22
·
1 Parent(s): 7134faa

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sklearn
2
+ import gradio as gr
3
+ import joblib
4
+ import pandas as pd
5
+
6
+ pipe = joblib.load("./model.pkl")
7
+
8
+ title = "Supersoaker Defective Product Prediction"
9
+ description = "This model predicts Supersoaker production line failures. The examples as of now are not parsed correctly, soon to be fixed. "
10
+
11
+
12
+ with open("./config.json") as f:
13
+ config_dict = eval(f.read())
14
+ headers = config_dict["sklearn"]["columns"]
15
+
16
+ example_dict = config_dict["sklearn"]["example_input"]
17
+ df = pd.DataFrame.from_dict(example_dict,orient='index').transpose()
18
+ examples=df.to_numpy().tolist()
19
+ final_examples = [[[example]] for example in examples]
20
+
21
+ inputs = gr.Dataframe(headers = [item for item in example_dict])
22
+ outputs = gr.Dataframe(headers = ["results"])
23
+
24
+
25
+ def infer(inputs):
26
+ data = pd.DataFrame(inputs, columns=[item for item in example_dict])
27
+ predictions = pipe.predict(inputs)
28
+ return pd.DataFrame(predictions, columns=["results"])
29
+
30
+ gr.Interface(infer, inputs = inputs, outputs = outputs, title = title,
31
+ description = description, examples=final_examples).launch(debug=True)