import gradio as gr import sys, os, io import pandas as pd sys.path.append(os.path.abspath('../src')) from idsc.idsc_apis import idsc_apis idsc = idsc_apis() def forecast(demand_table, product_table, storage_capacity): demand_table_df = pd.read_csv(demand_table.name) product_table_df = pd.read_csv(product_table.name) res = idsc.product_mix( demand_table_df.to_json(), product_table_df.to_json(), storage_capacity) return res def upload_file(file): return file.name def show(): return gr.update(visible=True) # demo = gr.Interface( # fn=forecast, # inputs=[ # demand_table_upload_btn, # product_table_upload_btn, # storage_capacity_input], # outputs="text") with gr.Blocks() as demo: demand_table_file = gr.File(visible=False) demand_table_upload_btn = gr.UploadButton( 'Demand Table', file_types=['.csv']) product_table_file = gr.File() product_table_upload_btn = gr.UploadButton( 'Product Table', file_types=['.csv']) storage_capacity_input = gr.Number( label='Storage Capacity', minimum=0) optimize_inventory_btn = gr.Button('Optimize') demand_table_upload_btn.upload( upload_file, demand_table_upload_btn, demand_table_file) demand_table_file.change(fn=show) demo.launch()