No Images Found – get_images_within_range() may not be selecting images correctly.
Empty Segmentation Output – get_segmented_images() might return an empty list.
Incorrect File Paths – Ensure TRAIN_DATA_PATH and "J0zdanvgrq" exist. Probably may be the issues but I suggest you to run code on pycharm or vscode environment and then see Use debugger to run code line by line to see Where your image went missing. It is difficult to pinpoint your img missing/empty reason from your code.
post your revelent code here to see what could be wrong?
Okay
**The function to segement the images**
# finally merge all of the image segments into one
def merge_segmented_images(path: Path, folder: str, side: str, start: int, end: int):
images_in_range = get_images_within_range(path, folder, side, start, end)
segmented_images = get_segmented_images(images_in_range)
# Determine final dimensions for the merged image
total_width = sum(img.width for img in segmented_images) # Sum of all widths
max_height = max(img.height for img in segmented_images) # Max height among all images
# Create a blank canvas with a transparent background
merged_images = Image.new("RGBA", (total_width, max_height), (0, 0, 0, 0))
# Paste each segmented image next to the previous one (left to right)
x_offset = 0
for img in segmented_images:
merged_images.paste(img, (x_offset, 0), img) # Paste at correct position
x_offset += img.width # Move x-offset to the right for the next image
return merged_images
merged_images = merge_segmented_images(TRAIN_DATA_PATH, "J0zdanvgrq", "R", 21, 28)
merged_images
**Set the Output directory**
OUTPUT_IMAGE_DIR = Path("/content/drive/MyDrive/segmentation/merged_images/")
os.makedirs(OUTPUT_IMAGE_DIR, exist_ok = True)
TRAIN_OUTPUT_DIR = OUTPUT_IMAGE_DIR / "Train"
TEST_OUTPUT_DIR = OUTPUT_IMAGE_DIR / "Test"
os.makedirs(TRAIN_OUTPUT_DIR, exist_ok = True)
os.makedirs(TEST_OUTPUT_DIR, exist_ok = True)
Here is my code
Your train and test files might be empty due to:
I think path is correct but the two I don't know how to navigate about them