Datasets:
Formats:
webdataset
Size:
1M - 10M
Tags:
sgt
semantic-generative-tuning
unified-multimodal
image-segmentation
visual-understanding
visual-generation
License:
| import os | |
| def find_image_files(directory, output_prefix): | |
| # 定义常见的图片文件扩展名 | |
| image_extensions = ['.jpg', '.jpeg', '.png', '.bmp', '.gif', '.tiff'] | |
| # 初始化计数器和文件名 | |
| file_count = 0 | |
| output_file = f"{output_prefix}_{file_count}.txt" | |
| # 打开第一个输出文件 | |
| with open(output_file, 'w') as f: | |
| # 遍历指定目录及其子目录中的所有文件 | |
| for root, dirs, files in os.walk(directory): | |
| for file in files: | |
| # 获取文件的完整路径 | |
| file_path = os.path.join(root, file) | |
| # 获取文件的扩展名 | |
| file_extension = os.path.splitext(file_path)[1].lower() | |
| # 检查文件扩展名是否在图片文件扩展名列表中 | |
| if file_extension in image_extensions: | |
| # 将文件名写入输出文件 | |
| f.write(file_path + '\n') | |
| file_count += 1 | |
| # 每100000个文件名写入一个新文件 | |
| if file_count % 200000 == 0: | |
| f.close() | |
| output_file = f"{output_prefix}_{file_count}.txt" | |
| f = open(output_file, 'w') | |
| # 确保最后一个文件被正确关闭 | |
| f.close() | |
| # 使用示例 | |
| directory = '/group/40033/public_datasets/sam-qa/sam_selection/' # 替换为你的文件夹路径 | |
| output_prefix = 'image_files_sam' # 输出文件名前缀 | |
| find_image_files(directory, output_prefix) |