Spaces:
Running
Running
sunheycho
commited on
Commit
Β·
be7a2aa
1
Parent(s):
4e3ec65
Fix 'read of closed file' error in ImageProcessingAgent
Browse files- Load images fully into memory with .convert('RGB') to avoid file stream closure issues
- Ensures ViT model can access image data after stream is closed
- Fixes product comparison session error status
api.py
CHANGED
@@ -1009,7 +1009,9 @@ def start_product_comparison():
|
|
1009 |
img1 = request.files['image1']
|
1010 |
print(f"[DEBUG] πΌοΈ Processing image1: {img1.filename}")
|
1011 |
try:
|
1012 |
-
|
|
|
|
|
1013 |
print(f"[DEBUG] β
Image1 processed successfully")
|
1014 |
except Exception as e:
|
1015 |
print(f"[DEBUG] β Error processing image1: {e}")
|
@@ -1018,7 +1020,9 @@ def start_product_comparison():
|
|
1018 |
img2 = request.files['image2']
|
1019 |
print(f"[DEBUG] πΌοΈ Processing image2: {img2.filename}")
|
1020 |
try:
|
1021 |
-
|
|
|
|
|
1022 |
print(f"[DEBUG] β
Image2 processed successfully")
|
1023 |
except Exception as e:
|
1024 |
print(f"[DEBUG] β Error processing image2: {e}")
|
|
|
1009 |
img1 = request.files['image1']
|
1010 |
print(f"[DEBUG] πΌοΈ Processing image1: {img1.filename}")
|
1011 |
try:
|
1012 |
+
# Load image and convert to RGB to ensure it's fully loaded in memory
|
1013 |
+
image = Image.open(img1.stream).convert('RGB')
|
1014 |
+
images.append(image)
|
1015 |
print(f"[DEBUG] β
Image1 processed successfully")
|
1016 |
except Exception as e:
|
1017 |
print(f"[DEBUG] β Error processing image1: {e}")
|
|
|
1020 |
img2 = request.files['image2']
|
1021 |
print(f"[DEBUG] πΌοΈ Processing image2: {img2.filename}")
|
1022 |
try:
|
1023 |
+
# Load image and convert to RGB to ensure it's fully loaded in memory
|
1024 |
+
image = Image.open(img2.stream).convert('RGB')
|
1025 |
+
images.append(image)
|
1026 |
print(f"[DEBUG] β
Image2 processed successfully")
|
1027 |
except Exception as e:
|
1028 |
print(f"[DEBUG] β Error processing image2: {e}")
|