🐳批量加载:
The SmartBatchLoader is a versatile and intelligent node designed to facilitate the efficient loading of batches of files from a specified folder. Its primary purpose is to streamline the process of handling large datasets by allowing you to specify various parameters that control how files are selected, grouped, and processed. This node is particularly beneficial for AI artists who need to manage and manipulate large collections of images and text files, as it supports multiple file types and offers options for grouping, shuffling, and resizing. By automating these tasks, the SmartBatchLoader enhances productivity and ensures that data is prepared in a consistent and organized manner, making it an essential tool for any workflow that involves batch processing of files.
🐳批量加载 Input Parameters:
folder_path
This parameter specifies the path to the folder containing the files you wish to load. It is a string input where you can enter the directory path, and it serves as the starting point for the batch loading process. The default value is an empty string, and it acts as a placeholder for the folder path you need to input.
file_type
This parameter determines the type of files to be loaded from the specified folder. You can choose from options such as "图像" (image), "文本" (text), "混合" (mixed), and "图像+文本" (image_text). The default setting is "图像," which means only image files will be loaded unless specified otherwise. This parameter allows you to filter the files based on their type, ensuring that only relevant files are processed.
batch_size
This integer parameter defines the number of files to be included in each batch. It ranges from a minimum of 1 to a maximum of 64, with a default value of 1. Adjusting the batch size impacts the number of files processed simultaneously, which can affect the speed and efficiency of your workflow.
start_index
The start_index parameter is an integer that indicates the starting point in the file list from which to begin loading files. It has a minimum value of 0 and a maximum of 99999, with a default value of 0. This parameter is useful for resuming batch processing from a specific point in the dataset.
shuffle
This boolean parameter determines whether the order of files should be randomized. When set to true, the files are shuffled, and when false, they are loaded in their original order. The default value is false, and this parameter is useful for introducing randomness into the batch loading process.
seed
The seed parameter is an integer used to initialize the random number generator for shuffling files. It has a default value of -1, which means no specific seed is set. By providing a seed value, you can ensure that the shuffling process is reproducible, which is important for experiments requiring consistent results.
group_by
This parameter allows you to group files based on specific criteria such as "无" (none), "扩展名" (extension), "前缀" (prefix), and "日期" (date). The default setting is "无," meaning no grouping is applied. Grouping files can help organize them into meaningful categories, facilitating more targeted processing.
resize_mode
The resize_mode parameter specifies how images should be resized, with options including "无" (none), "缩放" (resize), "裁剪" (crop), and "填充" (pad). The default is "无," indicating no resizing. This parameter is crucial for ensuring that images meet specific size requirements for further processing.
text_mode
This parameter determines how text files are paired with images, offering options like "配对" (paired) and "随机" (random). The default is "配对," meaning each image is paired with a corresponding text file. This setting is important for tasks that require synchronized image-text data.
🐳批量加载 Output Parameters:
image
This output parameter provides the loaded image data as a tensor. It is essential for any image processing tasks you plan to perform, as it contains the visual information extracted from the files in the specified folder.
text
The text output parameter contains the text data associated with the loaded files. This is particularly important when working with datasets that include both images and text, as it allows you to access and manipulate the textual content.
filename
This parameter outputs the name of the file currently being processed. It is useful for tracking and logging purposes, enabling you to identify which files are included in each batch.
selected_index
The selected_index output provides the index of the file within the batch. This information is valuable for understanding the order in which files are processed and for debugging purposes.
len(files)
This output parameter indicates the total number of files available in the specified folder. It helps you understand the size of your dataset and plan your batch processing accordingly.
metadata
The metadata output contains additional information about the files, such as their properties and attributes. This data can be useful for advanced processing tasks that require detailed file information.
🐳批量加载 Usage Tips:
- To optimize performance, adjust the
batch_sizeparameter according to your system's capabilities and the size of your dataset. - Use the
shuffleparameter with a specificseedvalue to ensure reproducibility in experiments that require randomized data. - Utilize the
group_byparameter to organize files into meaningful categories, which can simplify subsequent processing tasks. - Experiment with different
resize_modesettings to ensure that images meet the size requirements for your specific use case.
🐳批量加载 Common Errors and Solutions:
"FileNotFoundError: No such file or directory"
- Explanation: This error occurs when the specified
folder_pathdoes not exist or is incorrect. - Solution: Double-check the folder path for typos and ensure that the directory exists on your system.
"IndexError: list index out of range"
- Explanation: This error can happen if the
start_indexis set beyond the number of available files. - Solution: Verify that the
start_indexis within the range of the total number of files in the folder.
"ValueError: Invalid file type"
- Explanation: This error arises when an unsupported file type is specified in the
file_typeparameter. - Solution: Ensure that the
file_typeis set to one of the supported options: "图像," "文本," "混合," or "图像+文本."
