zhang qiao
Upload folder using huggingface_hub
49ba314
import gradio as gr
from src.gr.GradioApp import GradioApp
from src.gr import gr_args
# =============================== #
# Inventory Optimization Demo App #
# =============================== #
app = GradioApp()
demo = gr.Blocks(**gr_args.main_block)
with demo:
gr.Markdown('# Inventory Optimization')
with gr.Tabs() as tabs:
# ============================ #
# Raw Material Optimization #
# ============================ #
with gr.TabItem('Raw Material Optimization', id=0):
with gr.Row():
with gr.Column():
# Inventory Optimization #
rm_md = gr.Markdown(**gr_args.rm_md)
with gr.Row():
# [ Load Demo Dataset ] #
rm_demo_data_btn = gr.Button(
**gr_args.rm_demo_data_btn)
rm_file = gr.File(**gr_args.rm_file)
# [Inventory Optimization Input] #
rm_input_df = gr.Dataframe(**gr_args.rm_input_df)
with gr.Row():
# [FG Storage Capacity] #
rm_storage_capacity = gr.Number(
**gr_args.rm_storage_capacity)
# [FG Budget] #
rm_budget_constraint = gr.Number(
**gr_args.rm_budget_constraint)
# [Optimize Raw Material Inventory] #
rm_btn = gr.Button(**gr_args.rm_btn)
gr.Markdown('# Raw Material Inventory Recommendations')
with gr.Row():
rm_total_capacity_usage_md = gr.Markdown()
rm_total_budget_usage_md = gr.Markdown()
rm_recom_df = gr.Dataframe()
rm_plot = gr.Plot()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# Raw Material Event Listeners #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
rm_demo_data_btn.click(
app.rm_demo_data_btn__click,
[], [rm_input_df, rm_storage_capacity, rm_budget_constraint])
rm_file.upload(
app.rm_file__upload,
[rm_file], [rm_input_df])
rm_storage_capacity.change(
app.rm_storage_capacity__change,
[rm_storage_capacity], [])
rm_budget_constraint.change(
app.rm_budget_constraint__change,
[rm_budget_constraint], [])
rm_btn.click(
app.rm_btn__click,
[],
[rm_recom_df,
rm_total_capacity_usage_md,
rm_total_budget_usage_md,
rm_plot])
# ================ #
# WIP Optimization #
# ================ #
with gr.TabItem('WIP Optimization', id=1):
with gr.Row():
with gr.Column():
# Inventory Optimization #
wip_md = gr.Markdown(**gr_args.wip_md)
with gr.Row():
# [ Load Demo Dataset ] #
wip_demo_data_btn = gr.Button(
**gr_args.wip_demo_data_btn)
wip_file = gr.File(**gr_args.wip_file)
# [Inventory Optimization Input] #
wip_input_df = gr.Dataframe(**gr_args.wip_input_df)
with gr.Row():
# [FG Storage Capacity] #
wip_storage_capacity = gr.Number(
**gr_args.wip_storage_capacity)
# [FG Budget] #
wip_budget_constraint = gr.Number(
**gr_args.wip_budget_constraint)
# [Optimize Raw Material Inventory] #
wip_btn = gr.Button(**gr_args.wip_btn)
gr.Markdown('# WIP Inventory Recommendations')
with gr.Row():
wip_total_capacity_usage_md = gr.Markdown()
wip_total_budget_usage_md = gr.Markdown()
wip_recom_df = gr.Dataframe()
wip_plot = gr.Plot()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# WIP Event Listeners #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
wip_demo_data_btn.click(
app.wip_demo_data_btn__click,
[], [wip_input_df, wip_storage_capacity, wip_budget_constraint])
wip_file.upload(
app.wip_file__upload,
[wip_file], [wip_input_df])
wip_storage_capacity.change(
app.wip_storage_capacity__change,
[wip_storage_capacity], [])
wip_budget_constraint.change(
app.wip_budget_constraint__change,
[wip_budget_constraint], [])
wip_btn.click(
app.wip_btn__click,
[],
[wip_recom_df,
wip_total_capacity_usage_md,
wip_total_budget_usage_md,
wip_plot])
# ============================ #
# Finishend Goods Optimization #
# ============================ #
with gr.TabItem('FG Optimization', id=2):
with gr.Row():
with gr.Column():
# Inventory Optimization #
inventory_md = gr.Markdown(**gr_args.inventory_md)
with gr.Row():
# [ Load Demo Dataset ] #
demo_data_btn = gr.Button(**gr_args.demo_data_btn)
inventory_file = gr.File(**gr_args.inventory_file)
# [Inventory Optimization Input] #
inventory_input_df = gr.Dataframe(**gr_args.inventory_input_df)
with gr.Row():
# [FG Storage Capacity] #
inventory_storage_capacity = gr.Number(
**gr_args.inventory_storage_capacity)
# [FG Budget] #
inventory_budget_constraint = gr.Number(
**gr_args.inventory_budget_constraint)
# [Optimize Inventory] #
inventory_btn = gr.Button(**gr_args.inventory_btn)
gr.Markdown('# Inventory Recommendations')
with gr.Row():
inv_total_profit_md = gr.Markdown()
inv_total_capacity_usage_md = gr.Markdown()
inv_total_budget_usage_md = gr.Markdown()
inv_total_margin_md = gr.Markdown()
inv_recom_df = gr.Dataframe()
inv_plot = gr.Plot()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# FG Optimization Event Listeners #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
demo_data_btn.click(
app.demo_data_btn__click,
[], [inventory_input_df, inventory_storage_capacity, inventory_budget_constraint])
inventory_file.upload(
app.inventory_file__upload,
[inventory_file], [inventory_input_df])
inventory_storage_capacity.change(
app.inventory_storage_capacity__change,
[inventory_storage_capacity], [])
inventory_budget_constraint.change(
app.inventory_budget_constraint__change,
[inventory_budget_constraint], [])
inventory_btn.click(
app.inventory_btn__click,
[],
[inv_recom_df,
inv_total_profit_md,
inv_total_capacity_usage_md,
inv_total_budget_usage_md,
inv_total_margin_md,
inv_plot])
demo.launch()