Download utils/check_image_count.py from rrlab/RHLH-LVMs: direct link, hf CLI and curl.
- Browser
- Download file 561 Bytes
-
https://huggingface.co/rrlab/RHLH-LVMs/resolve/main/utils/check_image_count.py
- Command line
-
hf download hf://rrlab/RHLH-LVMs/utils/check_image_count.py
-
curl -L -o check_image_count.py https://huggingface.co/rrlab/RHLH-LVMs/resolve/main/utils/check_image_count.py
561 Bytes
| import os | |
| def count_images_in_directory(directory): | |
| # | |
| image_extensions = {'.jpg', '.jpeg', '.png', '.gif', '.bmp', '.tiff', '.tif'} | |
| image_count = 0 | |
| # | |
| for root, dirs, files in os.walk(directory): | |
| for file in files: | |
| # | |
| if os.path.splitext(file)[1].lower() in image_extensions: | |
| image_count += 1 | |
| return image_count | |
| # | |
| directory_path = '/mnt/RHLH-LVMs/Dataset_Demo/Town_demo_house' | |
| # | |
| total_images = count_images_in_directory(directory_path) | |
| print(f"total find {total_images} images.") | |