molinari135 commited on
Commit
c56dafe
·
verified ·
1 Parent(s): 4973050

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -24
app.py CHANGED
@@ -55,6 +55,7 @@ def predict_return(selected_products, total_customer_purchases, total_customer_r
55
  except requests.exceptions.RequestException as e:
56
  return f"Error: {str(e)}", ""
57
 
 
58
  # Predefined list of model-fabric-color combinations
59
  combinations = [
60
  "01CA9T-0130C-922",
@@ -65,43 +66,41 @@ combinations = [
65
  ]
66
 
67
  # Gradio interface elements
68
- inventory_column = gr.Column(
69
- [
70
- gr.CheckboxGroup(choices=combinations, label="Select Products", type="value"), # Scrollable inventory
71
- ]
72
- )
73
 
74
- user_info_column = gr.Column(
75
- [
76
- gr.Textbox(value="User Information\nTotal Purchases: 0\nTotal Returns: 0", label="User Info", interactive=False),
77
- ]
78
- )
79
 
80
- cart_column = gr.Column(
81
- [
82
- gr.Textbox(value="", label="Cart", interactive=False), # Cart details
83
- gr.Textbox(value="", label="Prediction Results", interactive=False), # Predictions for selected products
84
- ]
85
- )
86
 
87
  # Layout with two main columns: Left (Inventory) and Right (User Info + Cart)
88
  with gr.Row():
89
- gr.Column([inventory_column]) # Left side: Inventory
90
  with gr.Column():
91
- gr.Column([user_info_column]) # Right side: User Info
92
- gr.Column([cart_column]) # Right side: Cart & Predictions
 
 
 
 
93
 
94
  # Gradio Interface
95
  interface = gr.Interface(
96
  fn=predict_return, # Function to process predictions
97
  inputs=[
98
- inventory_column, # Left side: Inventory
99
- gr.Slider(0, 10, step=1, label="Total Customer Purchases", value=0), # Total purchases
100
- gr.Slider(0, 10, step=1, label="Total Customer Returns", value=0) # Total returns
101
  ],
102
  outputs=[
103
- cart_column, # Right side: Cart & Predictions
104
- user_info_column, # Right side: User Info
 
105
  ],
106
  live=True # Enable live interaction
107
  )
 
55
  except requests.exceptions.RequestException as e:
56
  return f"Error: {str(e)}", ""
57
 
58
+
59
  # Predefined list of model-fabric-color combinations
60
  combinations = [
61
  "01CA9T-0130C-922",
 
66
  ]
67
 
68
  # Gradio interface elements
69
+ inventory_checkbox_group = gr.CheckboxGroup(choices=combinations, label="Select Products", type="value")
 
 
 
 
70
 
71
+ # Slider elements for total purchases and returns
72
+ total_purchases_slider = gr.Slider(0, 10, step=1, label="Total Customer Purchases", value=0)
73
+ total_returns_slider = gr.Slider(0, 10, step=1, label="Total Customer Returns", value=0)
 
 
74
 
75
+ # Output elements for predictions and cart details
76
+ cart_output = gr.Textbox(value="", label="Cart", interactive=False)
77
+ predictions_output = gr.Textbox(value="", label="Prediction Results", interactive=False)
78
+
79
+ # User information output
80
+ user_info_output = gr.Textbox(value="User Information\nTotal Purchases: 0\nTotal Returns: 0", label="User Info", interactive=False)
81
 
82
  # Layout with two main columns: Left (Inventory) and Right (User Info + Cart)
83
  with gr.Row():
 
84
  with gr.Column():
85
+ inventory_checkbox_group # Left side: Inventory
86
+ with gr.Column():
87
+ user_info_output # Right side: User Info
88
+ cart_output # Right side: Cart & Predictions
89
+ predictions_output # Right side: Prediction Results
90
+
91
 
92
  # Gradio Interface
93
  interface = gr.Interface(
94
  fn=predict_return, # Function to process predictions
95
  inputs=[
96
+ inventory_checkbox_group, # Left side: Inventory
97
+ total_purchases_slider, # Total purchases
98
+ total_returns_slider # Total returns
99
  ],
100
  outputs=[
101
+ predictions_output, # Right side: Cart & Predictions
102
+ user_info_output, # Right side: User Info
103
+ cart_output # Right side: Cart
104
  ],
105
  live=True # Enable live interaction
106
  )