Before you fill out this form:
Did you review the FAQ?
Did you look through previous (open AND closed) issues posted on GH?
Now fill this form out completely:
Describe the bug
I was using cellpose/gui/make_train.py to generate 2D slices for 3D simulated data, where the ground-truth label masks were saved as TIFF (instead of GUI-generated _seg.npy files) which surfaced some bugs and gaps in the existing workflow:
1. TIFF Label Masks Not Supported
make_train.py expects pickled _seg.npy dicts with {"masks": array} format. TIFF labels must be manually converted before use.
Request: Accept TIFF label images directly as input.
2. Many Empty Crops in Training Set
In make_train slice selection is random with no mask-count filtering. Empty slices are saved and dropped later during training, reducing usable crops well below nimg_per_tif.
Suggestion: Filter slices by minimum mask count in make_train itself.
3. Masks Not Being Saved (Bug)
There is a bug in the make_train code where io.masks_flows_to_seg() call is nested inside the except ImportError block for skimage, with skimage installed, this code never runs. Only slices for raw image, image .tif are saved; mask _seg.py files are skipped.
Fix: Move io.masks_flows_to_seg() to the success path after skimage import.
Run log
img_crop = img[ly:ly + crop_size, lx:lx + crop_size].squeeze()
# Moved out of the `if masks0 is not None` block below.
# Otherwise only one of image/mask is saved, never both.
io.imsave(fname, img_crop)
if masks0 is not None:
masks_crop = masks[k][ly:ly + crop_size, lx:lx + crop_size].squeeze()
try:
from skimage.measure import label
masks_crop = label(masks_crop)
except ImportError:
print("skimage not found, cannot relabel masks. Run `pip install scikit-image` to relabel and save masks.")
# Moved out of the `except` block: previously the mask _seg.npy
# was only saved when skimage failed to import, so with skimage
# installed (normal case) mask crops were silently dropped.
flows = [np.zeros(masks_crop.shape, dtype="uint8"),
np.zeros((2, *masks_crop.shape), dtype="uint8"),
np.zeros(masks_crop.shape, dtype="float32")]
io.masks_flows_to_seg(img_crop, masks_crop, flows, fname)
Before you fill out this form:
Did you review the FAQ?
Did you look through previous (open AND closed) issues posted on GH?
Now fill this form out completely:
Describe the bug
I was using cellpose/gui/make_train.py to generate 2D slices for 3D simulated data, where the ground-truth label masks were saved as TIFF (instead of GUI-generated _seg.npy files) which surfaced some bugs and gaps in the existing
workflow:1. TIFF Label Masks Not Supported
make_train.py expects pickled _seg.npy dicts with {"masks": array} format. TIFF labels must be manually converted before use.
Request: Accept TIFF label images directly as input.
2. Many Empty Crops in Training Set
In make_train slice selection is random with no mask-count filtering. Empty slices are saved and dropped later during training, reducing usable crops well below nimg_per_tif.
Suggestion: Filter slices by minimum mask count in make_train itself.
3. Masks Not Being Saved (Bug)
There is a bug in the make_train code where io.masks_flows_to_seg() call is nested inside the except ImportError block for skimage, with skimage installed, this code never runs. Only slices for raw image, image .tif are saved; mask _seg.py files are skipped.
Fix: Move io.masks_flows_to_seg() to the success path after skimage import.
Run log