Skip to content

Make a graceful warning when encountering non-image file in input folder  #4

Description

@roperi

If the script encounters a non-image file it fails with the following warning:

Processing:  50% 1/2 [00:03<00:03,  3.72s/it]/usr/local/lib/python3.10/dist-packages/face_crop_plus/utils.py:264: UserWarning: Could not read the image input/.ipynb_checkpoints
  warnings.warn(f"Could not read the image {path}")
Processing:  50% 1/2 [00:03<00:03,  3.72s/it]
Traceback (most recent call last):
  File "/usr/local/bin/face-crop-plus", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/face_crop_plus/__main__.py", line 278, in main
    cropper.process_dir(input_dir, output_dir)
  File "/usr/local/lib/python3.10/dist-packages/face_crop_plus/cropper.py", line 909, in process_dir
    list(imap)
  File "/usr/local/lib/python3.10/dist-packages/tqdm/std.py", line 1182, in __iter__
    for obj in iterable:
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 873, in next
    raise value
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/usr/local/lib/python3.10/dist-packages/face_crop_plus/cropper.py", line 817, in process_batch
    images, _, paddings = as_batch(images, self.resize_size)
  File "/usr/local/lib/python3.10/dist-packages/face_crop_plus/utils.py", line 342, in as_batch
    return np.stack(img_batch), np.stack(unscales), np.stack(paddings)
  File "<__array_function__ internals>", line 180, in stack
  File "/usr/local/lib/python3.10/dist-packages/numpy/core/shape_base.py", line 422, in stack
    raise ValueError('need at least one array to stack')
ValueError: need at least one array to stack

First time I saw it i thought no image in the input folder was cropped.

EDIT: I know one should put images in the input folder but sometimes some hidden files are created as it happens when running script from a Google's Colab (as seen in example above).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions