kevalfst commited on
Commit
3993b73
·
verified ·
1 Parent(s): 89f28de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -1,15 +1,17 @@
1
  import os
2
  import subprocess
3
  import gradio as gr
4
- from predict import predict_transaction
5
 
6
- # Ensure the model directory exists and model is trained
7
  if not (os.path.exists("model/model.pkl") and os.path.exists("model/encoders.pkl")):
8
  print("Model files not found. Training model...")
9
  os.makedirs("model", exist_ok=True)
10
  subprocess.run(["python", "train.py"], check=True)
11
 
12
- # Gradio UI wrapper
 
 
 
13
  def predict_ui(check_id, employee_id, total, discount_amount, item_count, time, terminal_id):
14
  return predict_transaction({
15
  "check_id": check_id,
 
1
  import os
2
  import subprocess
3
  import gradio as gr
 
4
 
5
+ # Ensure model is trained
6
  if not (os.path.exists("model/model.pkl") and os.path.exists("model/encoders.pkl")):
7
  print("Model files not found. Training model...")
8
  os.makedirs("model", exist_ok=True)
9
  subprocess.run(["python", "train.py"], check=True)
10
 
11
+ # Import AFTER model is guaranteed to exist
12
+ from predict import predict_transaction
13
+
14
+ # Gradio UI
15
  def predict_ui(check_id, employee_id, total, discount_amount, item_count, time, terminal_id):
16
  return predict_transaction({
17
  "check_id": check_id,