Spaces:
Build error
Build error
Commit
·
bd55da6
1
Parent(s):
834d05a
Update app.py
Browse files
app.py
CHANGED
|
@@ -80,7 +80,6 @@ def generate_caption(processor, model, image):
|
|
| 80 |
logging.info('Finished generate_caption')
|
| 81 |
return generated_caption
|
| 82 |
|
| 83 |
-
# Function to save dataframe results to a CSV string for download
|
| 84 |
def save_dataframe_to_csv(df):
|
| 85 |
csv_buffer = io.StringIO()
|
| 86 |
df.to_csv(csv_buffer, index=False)
|
|
@@ -91,8 +90,8 @@ def save_dataframe_to_csv(df):
|
|
| 91 |
temp_file.write(csv_string)
|
| 92 |
temp_file_path = temp_file.name # Get the file path
|
| 93 |
|
| 94 |
-
#
|
| 95 |
-
return
|
| 96 |
|
| 97 |
# Main function to perform image captioning and image-text matching
|
| 98 |
def process_images_and_statements(image):
|
|
@@ -136,7 +135,7 @@ def process_images_and_statements(image):
|
|
| 136 |
|
| 137 |
# Return both the DataFrame and the CSV data for the Gradio interface
|
| 138 |
return results_df, csv_results # <--- Return results_df and csv_results
|
| 139 |
-
|
| 140 |
# Gradio interface
|
| 141 |
image_input = gr.inputs.Image()
|
| 142 |
output_df = gr.outputs.Dataframe(type="pandas", label="Results")
|
|
|
|
| 80 |
logging.info('Finished generate_caption')
|
| 81 |
return generated_caption
|
| 82 |
|
|
|
|
| 83 |
def save_dataframe_to_csv(df):
|
| 84 |
csv_buffer = io.StringIO()
|
| 85 |
df.to_csv(csv_buffer, index=False)
|
|
|
|
| 90 |
temp_file.write(csv_string)
|
| 91 |
temp_file_path = temp_file.name # Get the file path
|
| 92 |
|
| 93 |
+
# Return the file path (no need to reopen the file with "rb" mode)
|
| 94 |
+
return temp_file_path
|
| 95 |
|
| 96 |
# Main function to perform image captioning and image-text matching
|
| 97 |
def process_images_and_statements(image):
|
|
|
|
| 135 |
|
| 136 |
# Return both the DataFrame and the CSV data for the Gradio interface
|
| 137 |
return results_df, csv_results # <--- Return results_df and csv_results
|
| 138 |
+
|
| 139 |
# Gradio interface
|
| 140 |
image_input = gr.inputs.Image()
|
| 141 |
output_df = gr.outputs.Dataframe(type="pandas", label="Results")
|