darsoarafa commited on
Commit
18acca1
·
verified ·
1 Parent(s): a39f0e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -61,6 +61,7 @@ def generate_charts(pl_df, cf_df):
61
  # Save PL chart to BytesIO
62
  pl_chart_io = BytesIO()
63
  plt.savefig(pl_chart_io, format='png')
 
64
  plt.close()
65
  pl_chart_io.seek(0)
66
  pl_chart_base64 = base64.b64encode(pl_chart_io.read()).decode('utf-8')
@@ -78,10 +79,12 @@ def generate_charts(pl_df, cf_df):
78
  # Save CF chart to BytesIO
79
  cf_chart_io = BytesIO()
80
  plt.savefig(cf_chart_io, format='png')
 
81
  plt.close()
82
  cf_chart_io.seek(0)
83
  cf_chart_base64 = base64.b64encode(cf_chart_io.read()).decode('utf-8')
84
 
 
85
  return pl_chart_base64, cf_chart_base64
86
 
87
  def generate_financials(assumptions_text):
@@ -155,8 +158,8 @@ def generate_financials(assumptions_text):
155
 
156
  # Generate charts
157
  pl_chart_base64, cf_chart_base64 = generate_charts(pl_df, cf_df)
158
- return 'financial_projections.xlsx', f"data:image/png;base64,{pl_chart_base64}", f"data:image/png;base64,{cf_chart_base64}"
159
-
160
  # Gradio interface
161
  with gr.Blocks() as demo:
162
  gr.Markdown("# Financial Projections for Tea Production Machine Replacement")
 
61
  # Save PL chart to BytesIO
62
  pl_chart_io = BytesIO()
63
  plt.savefig(pl_chart_io, format='png')
64
+ plt.savefig('pl_chart_base64.png') # Save the image
65
  plt.close()
66
  pl_chart_io.seek(0)
67
  pl_chart_base64 = base64.b64encode(pl_chart_io.read()).decode('utf-8')
 
79
  # Save CF chart to BytesIO
80
  cf_chart_io = BytesIO()
81
  plt.savefig(cf_chart_io, format='png')
82
+ plt.savefig('cf_chart_base64.png') # Save the image
83
  plt.close()
84
  cf_chart_io.seek(0)
85
  cf_chart_base64 = base64.b64encode(cf_chart_io.read()).decode('utf-8')
86
 
87
+
88
  return pl_chart_base64, cf_chart_base64
89
 
90
  def generate_financials(assumptions_text):
 
158
 
159
  # Generate charts
160
  pl_chart_base64, cf_chart_base64 = generate_charts(pl_df, cf_df)
161
+ #return 'financial_projections.xlsx', f"data:image/png;base64,{pl_chart_base64}", f"data:image/png;base64,{cf_chart_base64}"
162
+ return 'financial_projections.xlsx','pl_chart_base64.png','cf_chart_base64.png'
163
  # Gradio interface
164
  with gr.Blocks() as demo:
165
  gr.Markdown("# Financial Projections for Tea Production Machine Replacement")