MouseLand / cellpose

a generalist algorithm for cellular segmentation with human-in-the-loop capabilities
https://www.cellpose.org/
BSD 3-Clause "New" or "Revised" License
1.24k stars 359 forks source link

[BUG] TypeError: 'NoneType' object is not subscriptable #940

Closed ZZQ-dev closed 1 month ago

ZZQ-dev commented 1 month ago

When we training models with command line, we will get this traceback.

Traceback (most recent call last):
  File "/home/gay17/anaconda3/envs/cellpose/bin/cellpose", line 8, in <module>
    sys.exit(main())
  File "/home/gay17/anaconda3/envs/cellpose/lib/python3.8/site-packages/cellpose/__main__.py", line 252, in main
    output = io.load_train_test_data(args.dir, test_dir, imf, args.mask_filter,
  File "/home/gay17/anaconda3/envs/cellpose/lib/python3.8/site-packages/cellpose/io.py", line 461, in load_train_test_data
    images, labels, image_names = load_images_labels(train_dir, mask_filter,
  File "/home/gay17/anaconda3/envs/cellpose/lib/python3.8/site-packages/cellpose/io.py", line 425, in load_images_labels
    if os.path.isfile(label_names[n]) or os.path.isfile(flow_names[0]):
TypeError: 'NoneType' object is not subscriptable

We need to go to "/home/gay17/anaconda3/envs/cellpose/lib/python3.8/site-packages/cellpose/io.py", line 425, replace if os.path.isfile(label_names[n]) or os.path.isfile(flow_names[0]): with if os.path.isfile(label_names[n]) or (flow_names is not None and os.path.isfile(flow_names[0])): Then the commond line works well.

carsen-stringer commented 1 month ago

thanks this is fixed now