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

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

Open
roperi opened this issue Aug 26, 2023 · 1 comment

Comments

@roperi
Copy link

roperi commented Aug 26, 2023

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).

@mantasu
Copy link
Owner

mantasu commented Aug 27, 2023

True, especially with Macs always putting their invisible .DS_Store

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants