Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,10 +7,9 @@ from code import (initialize_session,
|
|
| 7 |
visualize_all
|
| 8 |
)
|
| 9 |
|
| 10 |
-
def
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
return gr.File.update(value=filepath, label="Download Data")
|
| 14 |
|
| 15 |
with gr.Blocks(gr.themes.Soft(primary_hue="emerald",
|
| 16 |
font=[gr.themes.GoogleFont("Quicksand"),"ui-sans-serif", "system-ui", "sans-serif"],
|
|
@@ -70,9 +69,10 @@ with gr.Blocks(gr.themes.Soft(primary_hue="emerald",
|
|
| 70 |
with gr.Column(scale=1):
|
| 71 |
combine_button = gr.Button("Confirm")
|
| 72 |
with gr.Column(scale=1):
|
| 73 |
-
download_button = gr.
|
| 74 |
-
|
| 75 |
-
|
|
|
|
| 76 |
|
| 77 |
gr.Markdown("""
|
| 78 |
# Visualize Expenses
|
|
@@ -109,7 +109,7 @@ with gr.Blocks(gr.themes.Soft(primary_hue="emerald",
|
|
| 109 |
upload_button.click(image_to_df, inputs=[image_input, api_key_input], outputs=image_output)
|
| 110 |
upload_button.click(fn=lambda files: [file.name for file in files], inputs=image_input, outputs=uploaded_images)
|
| 111 |
combine_button.click(fn=update_combined_df, inputs=[image_output, session_id], outputs=[combined_df, receipt_count_text])
|
| 112 |
-
download_button.click(fn=
|
| 113 |
visualize_button.click(fn=visualize_all, inputs=[combined_df, month, budget], outputs=[fig1, fig2, fig3, fig4, fig5, fig6])
|
| 114 |
|
| 115 |
demo.launch(debug=True)
|
|
|
|
| 7 |
visualize_all
|
| 8 |
)
|
| 9 |
|
| 10 |
+
def export_csv(df):
|
| 11 |
+
df.to_csv("output.csv")
|
| 12 |
+
return gr.File.update(value="output.csv", visible=True)
|
|
|
|
| 13 |
|
| 14 |
with gr.Blocks(gr.themes.Soft(primary_hue="emerald",
|
| 15 |
font=[gr.themes.GoogleFont("Quicksand"),"ui-sans-serif", "system-ui", "sans-serif"],
|
|
|
|
| 69 |
with gr.Column(scale=1):
|
| 70 |
combine_button = gr.Button("Confirm")
|
| 71 |
with gr.Column(scale=1):
|
| 72 |
+
download_button = gr.Button("Export")
|
| 73 |
+
csv = gr.File(interactive=False, visible=False)
|
| 74 |
+
#with gr.Column(scale=1):
|
| 75 |
+
#receipt_count_text = gr.Textbox(label="Uploaded files:", interactive=False)
|
| 76 |
|
| 77 |
gr.Markdown("""
|
| 78 |
# Visualize Expenses
|
|
|
|
| 109 |
upload_button.click(image_to_df, inputs=[image_input, api_key_input], outputs=image_output)
|
| 110 |
upload_button.click(fn=lambda files: [file.name for file in files], inputs=image_input, outputs=uploaded_images)
|
| 111 |
combine_button.click(fn=update_combined_df, inputs=[image_output, session_id], outputs=[combined_df, receipt_count_text])
|
| 112 |
+
download_button.click(fn=export_csv, inputs=combined_df, outputs=csv)
|
| 113 |
visualize_button.click(fn=visualize_all, inputs=[combined_df, month, budget], outputs=[fig1, fig2, fig3, fig4, fig5, fig6])
|
| 114 |
|
| 115 |
demo.launch(debug=True)
|