Spaces:
Build error
Build error
iamrobotbear
commited on
Commit
·
ab23201
1
Parent(s):
bba9de5
well I was right that this wasn't gonna work
Browse files
app.py
CHANGED
@@ -73,6 +73,14 @@ def save_dataframe_to_csv(df):
|
|
73 |
return temp_file_path
|
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')
|
@@ -127,7 +135,7 @@ def process_images_and_statements(file):
|
|
127 |
return results_df, csv_results # <--- Return results_df and csv_results
|
128 |
|
129 |
# Gradio interface
|
130 |
-
file_input = gr.inputs.File(
|
131 |
output_df = gr.outputs.Dataframe(type="pandas", label="Results")
|
132 |
output_csv = gr.outputs.File(label="Download CSV")
|
133 |
|
|
|
73 |
return temp_file_path
|
74 |
|
75 |
|
76 |
+
# Define a validation function to check if the uploaded file is an image
|
77 |
+
def validate_image_file(file):
|
78 |
+
allowed_extensions = [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff"]
|
79 |
+
file_extension = os.path.splitext(file.name)[1]
|
80 |
+
if file_extension.lower() not in allowed_extensions:
|
81 |
+
return "Invalid file type. Please upload an image file (e.g., .jpg, .png, .jpeg)."
|
82 |
+
return None
|
83 |
+
|
84 |
# Main function to perform image captioning and image-text matching
|
85 |
def process_images_and_statements(file):
|
86 |
logging.info('Starting process_images_and_statements')
|
|
|
135 |
return results_df, csv_results # <--- Return results_df and csv_results
|
136 |
|
137 |
# Gradio interface
|
138 |
+
file_input = gr.inputs.File(label="Upload Image", validate=validate_image_file) # Use File input for image upload
|
139 |
output_df = gr.outputs.Dataframe(type="pandas", label="Results")
|
140 |
output_csv = gr.outputs.File(label="Download CSV")
|
141 |
|