Update app.py
Browse files
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 |
-
|
69 |
-
[
|
70 |
-
gr.CheckboxGroup(choices=combinations, label="Select Products", type="value"), # Scrollable inventory
|
71 |
-
]
|
72 |
-
)
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
]
|
78 |
-
)
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
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 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
93 |
|
94 |
# Gradio Interface
|
95 |
interface = gr.Interface(
|
96 |
fn=predict_return, # Function to process predictions
|
97 |
inputs=[
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
],
|
102 |
outputs=[
|
103 |
-
|
104 |
-
|
|
|
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 |
)
|