🐳文件夹加载:
The AdvancedFolderLoader is a sophisticated tool designed to streamline the process of loading and managing files from a specified directory. Its primary purpose is to facilitate the efficient retrieval of images and their associated text files, making it an invaluable asset for AI artists who work with large datasets. This node offers a variety of modes for file selection, including random, indexed, and sequential, allowing for flexible and tailored data handling. By supporting recursive directory searches and customizable sorting options, the AdvancedFolderLoader ensures that users can easily access and organize their files according to their specific needs. Additionally, it provides a mechanism for pairing images with corresponding text files, enhancing the workflow for projects that require both visual and textual data. Overall, the AdvancedFolderLoader is an essential tool for managing complex file structures and optimizing data retrieval processes.
🐳文件夹加载 Input Parameters:
folder_path
This parameter specifies the path to the directory from which files will be loaded. It is crucial for determining the source location of the files you wish to work with. The default value is an empty string, and it does not support multiline input. You should provide a valid directory path to ensure the node functions correctly.
mode
The mode parameter dictates the method of file selection within the specified folder. It offers three options: "随机" (random), "索引" (index), and "顺序" (sequential). The default mode is "随机," which selects files randomly. Choosing "索引" allows you to specify a particular file index, while "顺序" processes files in order. This flexibility enables you to tailor the file loading process to your specific project requirements.
index
This integer parameter is used when the mode is set to "索引." It allows you to specify the exact index of the file you wish to load. The default value is 0, with a minimum of 0 and a maximum of 99999. Adjusting this parameter lets you pinpoint specific files within the folder.
seed
The seed parameter is an integer that influences the randomness of file selection when the mode is set to "随机." It has a default value of -1, with a range from -1 to 0xffffffffffffffff. By setting a specific seed, you can ensure reproducibility in random file selection, which is useful for consistent testing and experimentation.
pattern
This string parameter defines the filename pattern for selecting files. The default pattern is "," which matches all files. You can specify patterns like ".png" to filter files by type or name, allowing for more precise control over the files being loaded.
recursive
The recursive parameter is a boolean that determines whether the file search should include subdirectories. The default value is False, meaning only the current directory is searched. Setting it to True enables a recursive search, which is beneficial for projects with nested folder structures.
sort_by
This parameter specifies the sorting criterion for files within the folder. It offers three options: "名称" (name), "日期" (date), and "大小" (size), with "名称" as the default. Sorting files helps in organizing and accessing them according to your preferred order.
text_mode
The text_mode parameter determines how text files are paired with images. It provides two options: "配对" (paired) and "随机" (random), with "配对" as the default. This setting is crucial for projects that require synchronized image and text data, ensuring that the correct text file is associated with each image.
previous_index
This optional integer parameter stores the index of the previously loaded file. Its default value is -1. It is useful for tracking progress and ensuring continuity in file processing, especially in sequential or indexed modes.
🐳文件夹加载 Output Parameters:
图像
This output represents the loaded image file. It is the primary visual data retrieved from the specified folder, essential for any image-based project.
文本
The 文本 output provides the text content associated with the loaded image. This is particularly important for projects that require both visual and textual data, such as captioning or prompt-based tasks.
文件名
This output gives the filename of the loaded image, allowing you to identify and reference the specific file being processed.
索引
The 索引 output indicates the index of the currently loaded file within the folder. It is useful for tracking progress and managing file order during processing.
文件总数
This output provides the total number of files available in the specified folder. It helps in understanding the scope of the dataset and planning the processing workflow.
元数据
The 元数据 output contains additional metadata related to the loaded file, offering further context and information that may be relevant to your project.
🐳文件夹加载 Usage Tips:
- To optimize performance when working with large datasets, use the
recursiveparameter to include subdirectories only when necessary, as this can significantly increase processing time. - Utilize the
patternparameter to filter files by type or name, which can help streamline the loading process and focus on specific file types relevant to your project. - When working with paired image and text data, ensure that the
text_modeis set to "配对" to maintain the correct association between images and their corresponding text files.
🐳文件夹加载 Common Errors and Solutions:
"无法使用任何编码读取文本文件"
- Explanation: This error occurs when the node is unable to read a text file using any of the specified encodings.
- Solution: Ensure that the text files are encoded in a supported format. You may need to convert the files to a compatible encoding or check for file corruption.
"文件夹路径无效"
- Explanation: This error indicates that the provided folder path is invalid or does not exist.
- Solution: Double-check the folder path for typos or errors, and ensure that the directory exists and is accessible.
"索引超出范围"
- Explanation: This error occurs when the specified index is outside the range of available files in the folder.
- Solution: Verify the total number of files in the folder and adjust the index parameter accordingly to ensure it falls within the valid range.
