mayankchugh-learning commited on
Commit
d9abd71
·
verified ·
1 Parent(s): 5630363

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -25
app.py CHANGED
@@ -6,20 +6,20 @@ import json
6
  import gradio as gr
7
  import pandas as pd
8
 
9
- # from huggingface_hub import CommitScheduler
10
  from pathlib import Path
11
 
12
 
13
- # log_file = Path("logs/") / f"data_{uuid.uuid4()}.json"
14
- # log_folder = log_file.parent
15
 
16
- # scheduler = CommitScheduler(
17
- # repo_id="machine-failure-logs",
18
- # repo_type="dataset",
19
- # folder_path=log_folder,
20
- # path_in_repo="data",
21
- # every=2
22
- # )
23
 
24
  machine_failure_predictor = joblib.load('model.joblib')
25
 
@@ -47,20 +47,20 @@ def predict_machine_failure(air_temperature, process_temperature, rotational_spe
47
  data_point = pd.DataFrame([sample])
48
  prediction = machine_failure_predictor.predict(data_point).tolist()
49
 
50
- # with scheduler.lock:
51
- # with log_file.open("a") as f:
52
- # f.write(json.dumps(
53
- # {
54
- # 'Air temperature [K]': air_temperature,
55
- # 'Process temperature [K]': process_temperature,
56
- # 'Rotational speed [rpm]': rotational_speed,
57
- # 'Torque [Nm]': torque,
58
- # 'Tool wear [min]': tool_wear,
59
- # 'Type': type,
60
- # 'prediction': prediction[0]
61
- # }
62
- # ))
63
- # f.write("\n")
64
 
65
  return prediction[0]
66
 
@@ -72,7 +72,7 @@ demo = gr.Interface(
72
  title="Machine Failure Predictor",
73
  description="This API allows you to predict the machine failure status of an equipment",
74
  allow_flagging="auto",
75
- concurrency_limit=8
76
  )
77
 
78
  demo.queue()
 
6
  import gradio as gr
7
  import pandas as pd
8
 
9
+ from huggingface_hub import CommitScheduler
10
  from pathlib import Path
11
 
12
 
13
+ log_file = Path("logs/") / f"data_{uuid.uuid4()}.json"
14
+ log_folder = log_file.parent
15
 
16
+ scheduler = CommitScheduler(
17
+ repo_id="machine-failure-logs",
18
+ repo_type="dataset",
19
+ folder_path=log_folder,
20
+ path_in_repo="data",
21
+ every=2
22
+ )
23
 
24
  machine_failure_predictor = joblib.load('model.joblib')
25
 
 
47
  data_point = pd.DataFrame([sample])
48
  prediction = machine_failure_predictor.predict(data_point).tolist()
49
 
50
+ with scheduler.lock:
51
+ with log_file.open("a") as f:
52
+ f.write(json.dumps(
53
+ {
54
+ 'Air temperature [K]': air_temperature,
55
+ 'Process temperature [K]': process_temperature,
56
+ 'Rotational speed [rpm]': rotational_speed,
57
+ 'Torque [Nm]': torque,
58
+ 'Tool wear [min]': tool_wear,
59
+ 'Type': type,
60
+ 'prediction': prediction[0]
61
+ }
62
+ ))
63
+ f.write("\n")
64
 
65
  return prediction[0]
66
 
 
72
  title="Machine Failure Predictor",
73
  description="This API allows you to predict the machine failure status of an equipment",
74
  allow_flagging="auto",
75
+ concurrency_limit=16
76
  )
77
 
78
  demo.queue()