Hugo014 commited on
Commit
b3eb483
·
verified ·
1 Parent(s): abd8189

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +36 -36
app.py CHANGED
@@ -44,43 +44,43 @@ def predict_sales_batch(csv_file):
44
  except Exception as e:
45
  return f"Error calling backend: {str(e)}"
46
 
47
- # Create Gradio UI with tabs for single and batch
48
- with gr.Blocks() as demo:
49
- gr.Markdown("# Super Kart Product Sales Prediction App")
50
 
51
- with gr.Tab("Single Prediction"):
52
- product_weight = gr.Number(label="Product Weight", value=10.0, minimum=0.0, step=0.1)
53
- product_sugar_content = gr.Dropdown(label="Product Sugar Content", choices=["No Sugar", "Low Sugar", "Regular"], value="Low Sugar")
54
- product_allocated_area = gr.Number(label="Product Allocated Area (sq ft)", value=500.0, minimum=0.0, step=1.0)
55
- product_type = gr.Dropdown(label="Product Type", choices=[
56
- "Dairy", "Soft Drinks", "Meat", "Fruits and Vegetables", "Snack Foods", "Household",
57
- "Frozen Foods", "Baking Goods", "Canned", "Health and Hygiene", "Hard Drinks",
58
- "Breads", "Starchy Foods", "Breakfast", "Seafood", "Others"
59
- ], value="Dairy")
60
- product_mrp = gr.Number(label="Product MRP (price)", value=100.0, minimum=0.0, step=1.0)
61
- store_establishment_year = gr.Number(label="Store Establishment Year", value=2000, minimum=1900, maximum=2025, step=1)
62
- store_size = gr.Dropdown(label="Store Size", choices=["Small", "Medium", "High"], value="Medium")
63
- store_location_city_type = gr.Dropdown(label="Store Location City Type", choices=["Tier 3", "Tier 2", "Tier 1"], value="Tier 1")
64
- store_type = gr.Dropdown(label="Store Type", choices=[
65
- "Grocery Store", "Supermarket Type1", "Supermarket Type2", "Supermarket Type3"
66
- ], value="Supermarket Type1")
67
- output_single = gr.Textbox(label="Prediction Result")
68
- predict_button = gr.Button("Predict")
69
- predict_button.click(
70
- fn=predict_sales_single,
71
- inputs=[product_weight, product_sugar_content, product_allocated_area, product_type, product_mrp,
72
- store_establishment_year, store_size, store_location_city_type, store_type],
73
- outputs=output_single
74
- )
75
 
76
- with gr.Tab("Batch Prediction"):
77
- csv_file = gr.File(label="Upload CSV for Batch Prediction", file_types=[".csv"])
78
- output_batch = gr.JSON(label="Batch Prediction Results") # Better for displaying dict output
79
- batch_button = gr.Button("Predict Batch")
80
- batch_button.click(
81
- fn=predict_sales_batch,
82
- inputs=csv_file,
83
- outputs=output_batch
84
- )
85
 
86
  demo.launch(share=True) # Added share=True to avoid localhost error in restricted environments like Colab
 
44
  except Exception as e:
45
  return f"Error calling backend: {str(e)}"
46
 
47
+ # # Create Gradio UI with tabs for single and batch
48
+ # with gr.Blocks() as demo:
49
+ # gr.Markdown("# Super Kart Product Sales Prediction App")
50
 
51
+ # with gr.Tab("Single Prediction"):
52
+ # product_weight = gr.Number(label="Product Weight", value=10.0, minimum=0.0, step=0.1)
53
+ # product_sugar_content = gr.Dropdown(label="Product Sugar Content", choices=["No Sugar", "Low Sugar", "Regular"], value="Low Sugar")
54
+ # product_allocated_area = gr.Number(label="Product Allocated Area (sq ft)", value=500.0, minimum=0.0, step=1.0)
55
+ # product_type = gr.Dropdown(label="Product Type", choices=[
56
+ # "Dairy", "Soft Drinks", "Meat", "Fruits and Vegetables", "Snack Foods", "Household",
57
+ # "Frozen Foods", "Baking Goods", "Canned", "Health and Hygiene", "Hard Drinks",
58
+ # "Breads", "Starchy Foods", "Breakfast", "Seafood", "Others"
59
+ # ], value="Dairy")
60
+ # product_mrp = gr.Number(label="Product MRP (price)", value=100.0, minimum=0.0, step=1.0)
61
+ # store_establishment_year = gr.Number(label="Store Establishment Year", value=2000, minimum=1900, maximum=2025, step=1)
62
+ # store_size = gr.Dropdown(label="Store Size", choices=["Small", "Medium", "High"], value="Medium")
63
+ # store_location_city_type = gr.Dropdown(label="Store Location City Type", choices=["Tier 3", "Tier 2", "Tier 1"], value="Tier 1")
64
+ # store_type = gr.Dropdown(label="Store Type", choices=[
65
+ # "Grocery Store", "Supermarket Type1", "Supermarket Type2", "Supermarket Type3"
66
+ # ], value="Supermarket Type1")
67
+ # output_single = gr.Textbox(label="Prediction Result")
68
+ # predict_button = gr.Button("Predict")
69
+ # predict_button.click(
70
+ # fn=predict_sales_single,
71
+ # inputs=[product_weight, product_sugar_content, product_allocated_area, product_type, product_mrp,
72
+ # store_establishment_year, store_size, store_location_city_type, store_type],
73
+ # outputs=output_single
74
+ # )
75
 
76
+ # with gr.Tab("Batch Prediction"):
77
+ # csv_file = gr.File(label="Upload CSV for Batch Prediction", file_types=[".csv"])
78
+ # output_batch = gr.JSON(label="Batch Prediction Results") # Better for displaying dict output
79
+ # batch_button = gr.Button("Predict Batch")
80
+ # batch_button.click(
81
+ # fn=predict_sales_batch,
82
+ # inputs=csv_file,
83
+ # outputs=output_batch
84
+ # )
85
 
86
  demo.launch(share=True) # Added share=True to avoid localhost error in restricted environments like Colab