Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]Value Error when training Cellpose3 #1064

Open
SelinaHhan opened this issue Nov 25, 2024 · 0 comments
Open

[BUG]Value Error when training Cellpose3 #1064

SelinaHhan opened this issue Nov 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@SelinaHhan
Copy link

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:
Screen Shot 2024-11-24 at 19 49 07

Can anyone help me to debug this issue? Thanks in advance.

@SelinaHhan SelinaHhan added the bug Something isn't working label Nov 25, 2024
@SelinaHhan SelinaHhan changed the title [BUG] [BUG]Value Error when training Cellpose3 Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant