joheras commited on
Commit
14fa378
·
1 Parent(s): 736f47f
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -8,17 +8,19 @@ model = from_pretrained_keras("keras-io/timeseries_transformer_classification")
8
 
9
  def detect_issue(file):
10
  df = pd.read_csv(file,header=None)
11
- pred = model.predict(df)[0]
12
- problem = 'No problem'
13
- if(np.argmax(pred)==1):
14
- problem = 'Engine problem'
15
- return problem, pred[1]
16
 
17
 
18
  iface = gr.Interface(detect_issue,gr.inputs.File(label="csv file"),
19
- outputs=[
20
- gr.outputs.Textbox(label="Engine issue"),
21
- gr.outputs.Textbox(label="Engine issue score")], examples=["sample.csv"]
 
 
22
  # examples = ["sample.csv"],
23
  )
24
 
 
8
 
9
  def detect_issue(file):
10
  df = pd.read_csv(file,header=None)
11
+ preds = model.predict(df)
12
+ result = []
13
+ for i,pred in enumerate(preds):
14
+ result.append(['Sample ' + str(i+1), np.argmax(pred),pred[np.argmax(pred)]]
15
+ return pd.DataFrame(result,header=['Sample','class','confidence']
16
 
17
 
18
  iface = gr.Interface(detect_issue,gr.inputs.File(label="csv file"),
19
+ "dataframe",
20
+ #outputs=[
21
+ # gr.outputs.Textbox(label="Engine issue"),
22
+ # gr.outputs.Textbox(label="Engine issue score")],
23
+ examples=["sample.csv"]
24
  # examples = ["sample.csv"],
25
  )
26