Spaces:
Sleeping
Sleeping
Update apply_mask.py
Browse files- apply_mask.py +6 -1
apply_mask.py
CHANGED
@@ -33,7 +33,7 @@ def apply_mask_and_crop(input_folder, mask, output_folder):
|
|
33 |
return
|
34 |
|
35 |
print(f"Found {len(image_files)} images to process")
|
36 |
-
|
37 |
for img_path in image_files:
|
38 |
# Load image
|
39 |
img = cv2.imread(img_path)
|
@@ -68,6 +68,11 @@ def apply_mask_and_crop(input_folder, mask, output_folder):
|
|
68 |
|
69 |
# Save cropped image
|
70 |
cv2.imwrite(output_path, cropped_img)
|
|
|
|
|
|
|
|
|
|
|
71 |
# print(f"Processed and saved: {output_path}")
|
72 |
|
73 |
print(f"\nProcessing complete! Saved {len(image_files)} cropped images to {output_folder}")
|
|
|
33 |
return
|
34 |
|
35 |
print(f"Found {len(image_files)} images to process")
|
36 |
+
i = 0
|
37 |
for img_path in image_files:
|
38 |
# Load image
|
39 |
img = cv2.imread(img_path)
|
|
|
68 |
|
69 |
# Save cropped image
|
70 |
cv2.imwrite(output_path, cropped_img)
|
71 |
+
if i = 0:
|
72 |
+
preview_path = os.path.join(output_folder, f"preview_{filename}")
|
73 |
+
cv2.imwrite(preview_path, cropped_img)
|
74 |
+
return preview_path
|
75 |
+
i= i+1
|
76 |
# print(f"Processed and saved: {output_path}")
|
77 |
|
78 |
print(f"\nProcessing complete! Saved {len(image_files)} cropped images to {output_folder}")
|