///
The `sd-webui-infinite-image-browsing` project is designed with extensibility in mind, allowing users and developers to integrate support for new AI image generation software and extend functionality
12 views
~12 views from guests
Guest views are estimated from total page views. These include anonymous visitors and users who weren't logged in when they viewed the page.
The sd-webui-infinite-image-browsing project is designed with extensibility in mind, allowing users and developers to integrate support for new AI image generation software and extend functionality through custom parsers and plugins. This document outlines the mechanisms for extending the application.
The core of the application's extensibility revolves around two main points:
Image metadata parsers are crucial for Infinite Image Browsing to understand the various formats in which different AI generation tools embed information (like prompts, models, seeds, etc.) within image files.
The application's parser system, managed by scripts/iib/parsers/index.py, iterates through a list of registered parser classes. Each parser has a test method to determine if it can handle a given image. If test returns True, its parse method is called to extract the detailed generation information.
To create a new parser for unsupported AI software, follow these steps:
Create a New Python File:
scripts/iib/parsers/ directory.my_software.py).Define a Parser Class:
my_software.py, define a class (e.g., MySoftwareParser). This class must implement two static methods: test and parse.PIL.Image for image handling and ImageGenerationInfo, ImageGenerationParams from scripts/iib/parsers/model.py for structured output.Implement the test Method:
Image object and file_path as input.True if it can parse the image, False otherwise.Implement the parse Method:
test returns True. It takes the same inputs (Image object and file_path).ImageGenerationInfo object.ImageGenerationInfo object contains:
raw_info (str): The raw string of the generation information (e.g., the full prompt block).params (ImageGenerationParams): A structured object containing:
meta (dict): Key-value pairs of various parameters (e.g., Model, Sampler, Steps, CFG scale, Size, Source Identifier). The final_width and final_height should always be included here.pos_prompt (list): A list of positive prompt tags.extra (dict): Any additional parsed data, like Lora/LyCORIS information.New parser files placed in scripts/iib/parsers/ are automatically imported and added to the list of parsers in scripts/iib/parsers/index.py. The order of parsers in index.py matters; for example, the SdWebUIParser is usually the last one, acting as a general fallback if no other specialized parser matches.
Example Parsers: Refer to scripts/iib/parsers/comfyui.py, scripts/iib/parsers/fooocus.py, scripts/iib/parsers/novelai.py, and scripts/iib/parsers/stable_swarm_ui.py for concrete examples. The scripts/iib/parsers/sd_webui_stealth.py also demonstrates handling specific image formats (stealth PNG info) and can be enabled via the IIB_ENABLE_SD_WEBUI_STEALTH_PARSER environment variable (see .env.example).
General plugins provide a more flexible way to extend Infinite Image Browsing's functionality. They can be used for custom data processing, adding new "Source Identifier" specific logic, or integrating external services.
The scripts/iib/plugin.py script scans a designated plugins directory (relative to the project's root) for subdirectories containing a main.py file. It then imports and instantiates a Main class from each main.py file. These instances are stored and can be accessed by other parts of the application.
To create a general plugin:
Create a Plugin Directory:
plugins in the project's root.plugins/, create a subdirectory for your plugin (e.g., plugins/my_custom_plugin/).Create main.py:
main.py file.Main class within this main.py file:A key use case for general plugins is to specify additional metadata fields from your parser's output that should be automatically converted into searchable tags.
scripts/iib/db/update_image_data.py, the get_extra_meta_keys_from_plugins function retrieves the extra_convert_to_tag_meta_keys from loaded plugins.build_single_img_idx function), if an image's Source Identifier matches a plugin's source_identifier, the plugin's specified extra_convert_to_tag_meta_keys will be processed. The values corresponding to these keys in the image's metadata will be created as new tags (with the key as the tag type) and linked to the image.Developers are encouraged to contribute to sd-webui-infinite-image-browsing by adding support for new AI generation software or extending its functionality.
scripts/iib/parsers/ with a test and parse method as described in Section 1.Source Identifier: Make sure your parse method populates the meta["Source Identifier"] field with a unique string representing your software. This is crucial for distinguishing images and can be used by general plugins.plugins/your_plugin_name/main.py as described in Section 2.source_identifier: If your plugin is meant to enhance the processing of a specific AI software's images, ensure your source_identifier matches the Source Identifier reported by the corresponding parser.extra_convert_to_tag_meta_keys: List any additional metadata keys from your ImageGenerationParams.meta that you want to be automatically searchable as tags.Main class as needed.scripts/iib/parsers/index.py: The central hub for loading and orchestrating image metadata parsers.scripts/iib/parsers/model.py: Defines the ImageGenerationInfo and ImageGenerationParams data structures that all parsers must output.scripts/iib/parsers/*.py: Contains existing parser implementations (e.g., sd_webui.py, comfyui.py, fooocus.py, novelai.py, stable_swarm_ui.py, invoke_ai.py, sd_webui_stealth.py) as examples.scripts/iib/plugin.py: The script responsible for discovering and loading general plugins.scripts/iib/db/update_image_data.py: Contains the logic for processing image metadata and converting specified keys into tags, including those defined by plugins..env.example: Provides examples of environment variables that can configure certain parsing behaviors (e.g., IIB_ENABLE_SD_WEBUI_STEALTH_PARSER).