molinari135 commited on
Commit
a380fda
·
verified ·
1 Parent(s): ee45237

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -10,7 +10,7 @@ API_URL = "https://molinari135-product-return-prediction-api.hf.space/predict/"
10
  # Load the inventory dataset from Hugging Face
11
  hf_token = os.getenv("inventory_data")
12
  dataset = load_dataset("molinari135/armani-inventory", token=hf_token, data_files="inventory.tsv")
13
- inventory = pd.DataFrame(dataset['train']).head(15)
14
 
15
  # Gradio Interface function
16
  def predict_return(selected_products, total_customer_purchases, total_customer_returns):
@@ -27,7 +27,7 @@ def predict_return(selected_products, total_customer_purchases, total_customer_r
27
 
28
  for selected_product in selected_products:
29
  # Split each selected product into model, fabric, and color
30
- product_info = selected_product.split(" \t")
31
  model_fabric_colour = product_info[0] # Questo è del tipo "Model-Fabric-Colour"
32
 
33
  # Dividi il codice prodotto in modello, tessuto e colore
@@ -92,7 +92,7 @@ def predict_return(selected_products, total_customer_purchases, total_customer_r
92
  # Crea l'interfaccia Gradio con le checkbox a sinistra
93
  checkbox_choices = [
94
  f"{row['Item Brand Model']}-{row['Item Brand Fabric']}-{row['Item Brand Colour']}"
95
- f" \tType: {row['Product Type']} \tMaterial: {row['Main Material']} \tSales: {round(row['Net Sales (FA)'], 2)} USD"
96
  for _, row in inventory.iterrows()
97
  ]
98
 
 
10
  # Load the inventory dataset from Hugging Face
11
  hf_token = os.getenv("inventory_data")
12
  dataset = load_dataset("molinari135/armani-inventory", token=hf_token, data_files="inventory.tsv")
13
+ inventory = pd.DataFrame(dataset['train']).sample(n=15, random_state=42)
14
 
15
  # Gradio Interface function
16
  def predict_return(selected_products, total_customer_purchases, total_customer_returns):
 
27
 
28
  for selected_product in selected_products:
29
  # Split each selected product into model, fabric, and color
30
+ product_info = selected_product.split(" \t\t")
31
  model_fabric_colour = product_info[0] # Questo è del tipo "Model-Fabric-Colour"
32
 
33
  # Dividi il codice prodotto in modello, tessuto e colore
 
92
  # Crea l'interfaccia Gradio con le checkbox a sinistra
93
  checkbox_choices = [
94
  f"{row['Item Brand Model']}-{row['Item Brand Fabric']}-{row['Item Brand Colour']}"
95
+ f" \t\tType: {row['Product Type']} \t\tMaterial: {row['Main Material']} \t\tSales: {round(row['Net Sales (FA)'], 2)} USD"
96
  for _, row in inventory.iterrows()
97
  ]
98