Update app.py
Browse files
app.py
CHANGED
@@ -13,13 +13,13 @@ dataset = load_dataset("molinari135/armani-inventory", token=hf_token, data_file
|
|
13 |
inventory = pd.DataFrame(dataset['train']).head(50)
|
14 |
|
15 |
# Gradio Interface function
|
16 |
-
def predict_return(
|
17 |
# Input validation for returns (must be <= purchases)
|
18 |
if total_customer_returns > total_customer_purchases:
|
19 |
return "Error: Total returns cannot be greater than total purchases."
|
20 |
|
21 |
-
# Selezionare i prodotti scelti
|
22 |
-
selected_products = inventory.iloc[
|
23 |
|
24 |
# Preparare i dati per la predizione
|
25 |
models = selected_products['Item Brand Model'].tolist()
|
@@ -48,18 +48,15 @@ def predict_return(selected_rows, total_customer_purchases, total_customer_retur
|
|
48 |
return cart_details, formatted_result, total_cart
|
49 |
|
50 |
# Gradio interface elements
|
|
|
|
|
|
|
|
|
|
|
51 |
interface = gr.Interface(
|
52 |
fn=predict_return, # Funzione per la logica di predizione
|
53 |
inputs=[
|
54 |
-
gr.
|
55 |
-
value=inventory[['Item Brand Model', 'Item Brand Fabric', 'Item Brand Colour', 'Product Type', 'Main Material', 'Net Sales (FA)']],
|
56 |
-
headers=["Model", "Fabric", "Colour", "Type", "Material", "Sales (FA)"],
|
57 |
-
interactive=True, # Permette la selezione
|
58 |
-
col_count=6, # Numero di colonne
|
59 |
-
row_count=5, # Numero di righe visibili
|
60 |
-
checkbox_column='Checkbox', # Colonna checkbox
|
61 |
-
label="Select Products"
|
62 |
-
),
|
63 |
gr.Slider(0, 10, step=1, label="Total Customer Purchases", value=0),
|
64 |
gr.Slider(0, 10, step=1, label="Total Customer Returns", value=0)
|
65 |
],
|
|
|
13 |
inventory = pd.DataFrame(dataset['train']).head(50)
|
14 |
|
15 |
# Gradio Interface function
|
16 |
+
def predict_return(selected_indices, total_customer_purchases, total_customer_returns):
|
17 |
# Input validation for returns (must be <= purchases)
|
18 |
if total_customer_returns > total_customer_purchases:
|
19 |
return "Error: Total returns cannot be greater than total purchases."
|
20 |
|
21 |
+
# Selezionare i prodotti scelti usando gli indici
|
22 |
+
selected_products = inventory.iloc[selected_indices]
|
23 |
|
24 |
# Preparare i dati per la predizione
|
25 |
models = selected_products['Item Brand Model'].tolist()
|
|
|
48 |
return cart_details, formatted_result, total_cart
|
49 |
|
50 |
# Gradio interface elements
|
51 |
+
checkboxes = [
|
52 |
+
gr.Checkbox(label=f"{row['Item Brand Model']} - {row['Item Brand Fabric']} - {row['Item Brand Colour']}", value=False)
|
53 |
+
for _, row in inventory.iterrows()
|
54 |
+
]
|
55 |
+
|
56 |
interface = gr.Interface(
|
57 |
fn=predict_return, # Funzione per la logica di predizione
|
58 |
inputs=[
|
59 |
+
gr.Column([*checkboxes], label="Select Products"), # Aggiungi tutte le checkbox
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
gr.Slider(0, 10, step=1, label="Total Customer Purchases", value=0),
|
61 |
gr.Slider(0, 10, step=1, label="Total Customer Returns", value=0)
|
62 |
],
|