Value Error when training Cellpose3: train data and label not same length.
I have 10 image.tif in my training folder and masks folder which contain 10 corresponding masks. Then I store data = {
"train_files": images,
"train_labels": masks,
} to probs_generalist.npy. Finally, I use the command line from the paper to train the model. However, It has 'ValueError: train data and labels not same length.'
import numpy as np
# # Specify the directories for images and masks
image_dir = "/Users/selinahan/Desktop/training"
mask_dir = "/Users/selinahan/Desktop/training/masks"
# Get all image and mask file paths
# Assuming the filenames match (e.g., image1.tif → masks/image1_mask.tif)
images = sorted([os.path.join(image_dir, f) for f in os.listdir(image_dir) if f.endswith(".tif")])
masks = sorted([os.path.join(mask_dir, f) for f in os.listdir(mask_dir) if f.endswith(".tif")])
# Ensure matching filenames
if len(images) != len(masks):
raise ValueError("Number of images and masks do not match!")
# Create the dictionary
data = {
"train_files": images,
"train_labels": masks,
}
# Save as .npy file
np.save("/Users/selinahan/Desktop/training/probs_generalist.npy", data)
Command line shown in screenshots:
Can anyone help me to debug this issue? Thanks in advance.
Value Error when training Cellpose3: train data and label not same length.
I have 10 image.tif in my training folder and masks folder which contain 10 corresponding masks. Then I store data = { "train_files": images, "train_labels": masks, } to probs_generalist.npy. Finally, I use the command line from the paper to train the model. However, It has 'ValueError: train data and labels not same length.'
Command line shown in screenshots:
Can anyone help me to debug this issue? Thanks in advance.