Spaces:
Build error
Build error
iamrobotbear
commited on
Commit
·
cf785f9
1
Parent(s):
0041559
mega broken
Browse files
app.py
CHANGED
@@ -83,15 +83,15 @@ def is_image_file(file):
|
|
83 |
|
84 |
# Main function to perform image captioning and image-text matching
|
85 |
def process_images_and_statements(file):
|
86 |
-
|
87 |
if not is_image_file(file):
|
88 |
return "Invalid file type. Please upload an image file (e.g., .jpg, .png, .jpeg)."
|
89 |
|
90 |
# Extract the filename from the file object
|
91 |
filename = file.name
|
92 |
|
93 |
-
# Load the image data from the file
|
94 |
-
image = Image.open(file)
|
95 |
|
96 |
# Generate image caption for the uploaded image using git-large-r-textcaps
|
97 |
caption = generate_caption(git_processor_large_textcaps, git_model_large_textcaps, image)
|
|
|
83 |
|
84 |
# Main function to perform image captioning and image-text matching
|
85 |
def process_images_and_statements(file):
|
86 |
+
# Check if the uploaded file is an image
|
87 |
if not is_image_file(file):
|
88 |
return "Invalid file type. Please upload an image file (e.g., .jpg, .png, .jpeg)."
|
89 |
|
90 |
# Extract the filename from the file object
|
91 |
filename = file.name
|
92 |
|
93 |
+
# Load the image data from the file (convert file object to bytes using file.read())
|
94 |
+
image = Image.open(io.BytesIO(file.read()))
|
95 |
|
96 |
# Generate image caption for the uploaded image using git-large-r-textcaps
|
97 |
caption = generate_caption(git_processor_large_textcaps, git_model_large_textcaps, image)
|