Primary competition visual

CGIAR Root Volume Estimation Challenge

Helping Africa
$15 000 USD
Completed (~1 year ago)
Computer Vision
Prediction
1063 joined
257 active
Starti
Jan 24, 25
Closei
Mar 09, 25
Reveali
Mar 10, 25
User avatar
Ojuka
Mount Kenya University
Merged_images
Notebooks · 26 Feb 2025, 21:20 · 5

After merging all the image segments, I am getting empty train and test files. What could be the problem?

Discussion 5 answers
User avatar
MuhammadQasimShabbeer
Engmatix

post your revelent code here to see what could be wrong?

27 Feb 2025, 06:54
Upvotes 0
User avatar
Ojuka
Mount Kenya University

Okay

User avatar
Ojuka
Mount Kenya University

**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

27 Feb 2025, 11:17
Upvotes 0
User avatar
MuhammadQasimShabbeer
Engmatix

Your train and test files might be empty due to:

  1. No Images Foundget_images_within_range() may not be selecting images correctly.
  2. Empty Segmentation Outputget_segmented_images() might return an empty list.
  3. 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.
User avatar
Ojuka
Mount Kenya University

I think path is correct but the two I don't know how to navigate about them