Spaces:
Build error
Build error
iamrobotbear
commited on
Commit
·
bba9de5
1
Parent(s):
dbd7efa
pretty sure thi sisn't going to work
Browse files
app.py
CHANGED
@@ -74,11 +74,14 @@ def save_dataframe_to_csv(df):
|
|
74 |
|
75 |
|
76 |
# Main function to perform image captioning and image-text matching
|
77 |
-
def process_images_and_statements(
|
78 |
logging.info('Starting process_images_and_statements')
|
79 |
|
80 |
-
# Extract the filename from the file object
|
81 |
-
filename = file.name
|
|
|
|
|
|
|
82 |
|
83 |
# Generate image caption for the uploaded image using git-large-r-textcaps
|
84 |
caption = generate_caption(git_processor_large_textcaps, git_model_large_textcaps, image)
|
@@ -124,13 +127,13 @@ def process_images_and_statements(image, file):
|
|
124 |
return results_df, csv_results # <--- Return results_df and csv_results
|
125 |
|
126 |
# Gradio interface
|
127 |
-
|
128 |
output_df = gr.outputs.Dataframe(type="pandas", label="Results")
|
129 |
output_csv = gr.outputs.File(label="Download CSV")
|
130 |
|
131 |
iface = gr.Interface(
|
132 |
fn=process_images_and_statements,
|
133 |
-
inputs=
|
134 |
outputs=[output_df, output_csv],
|
135 |
title="Image Captioning and Image-Text Matching",
|
136 |
theme='sudeepshouche/minimalist',
|
|
|
74 |
|
75 |
|
76 |
# Main function to perform image captioning and image-text matching
|
77 |
+
def process_images_and_statements(file):
|
78 |
logging.info('Starting process_images_and_statements')
|
79 |
|
80 |
+
# Extract the filename from the file object
|
81 |
+
filename = file.name
|
82 |
+
|
83 |
+
# Load the image data from the file
|
84 |
+
image = Image.open(file)
|
85 |
|
86 |
# Generate image caption for the uploaded image using git-large-r-textcaps
|
87 |
caption = generate_caption(git_processor_large_textcaps, git_model_large_textcaps, image)
|
|
|
127 |
return results_df, csv_results # <--- Return results_df and csv_results
|
128 |
|
129 |
# Gradio interface
|
130 |
+
file_input = gr.inputs.File(type="image", label="Upload Image") # Use File input for image upload
|
131 |
output_df = gr.outputs.Dataframe(type="pandas", label="Results")
|
132 |
output_csv = gr.outputs.File(label="Download CSV")
|
133 |
|
134 |
iface = gr.Interface(
|
135 |
fn=process_images_and_statements,
|
136 |
+
inputs=file_input,
|
137 |
outputs=[output_df, output_csv],
|
138 |
title="Image Captioning and Image-Text Matching",
|
139 |
theme='sudeepshouche/minimalist',
|