Implementation:AUTOMATIC1111 Stable diffusion webui ExtraNetworksPageLora list items
| Knowledge Sources | |
|---|---|
| Domains | Stable Diffusion, LoRA, File Management, UI |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Concrete tool for scanning, filtering, and presenting LoRA network files in the Extra Networks UI panel, provided by the AUTOMATIC1111 stable-diffusion-webui repository.
Description
ExtraNetworksPageLora is a subclass of ExtraNetworksPage that implements the LoRA tab in the Extra Networks browser. Its list_items() method iterates over all available networks registered in networks.available_networks, creates a UI-friendly dictionary for each one via create_item(), and yields them as a generator. Each item dict includes the network name, filename, short hash, preview image path, description, search terms, metadata, SD version, sort keys, and a JavaScript-formatted prompt string for insertion.
The create_item() method handles SD version compatibility filtering: it compares the network's detected SD version against the currently loaded model and returns None for incompatible networks (unless lora_show_all is enabled). It also reads user metadata from sidecar JSON files to extract custom activation text, preferred weight, and negative prompt text.
Usage
This class is instantiated as a page in the Extra Networks UI. It is used whenever the user opens the LoRA tab in the Extra Networks panel or triggers a refresh. The yielded item dicts are consumed by the UI rendering system to display network cards with thumbnails, descriptions, and click-to-insert prompt functionality.
Code Reference
Source Location
- Repository: stable-diffusion-webui
- File:
extensions-builtin/Lora/ui_extra_networks_lora.py - Lines: 11-90
Signature
class ExtraNetworksPageLora(ui_extra_networks.ExtraNetworksPage):
def __init__(self):
super().__init__('Lora')
def refresh(self):
networks.list_available_networks()
def create_item(self, name, index=None, enable_filter=True):
...
def list_items(self):
# instantiate a list to protect against concurrent modification
names = list(networks.available_networks)
for index, name in enumerate(names):
item = self.create_item(name, index)
if item is not None:
yield item
def allowed_directories_for_previews(self):
return [shared.cmd_opts.lora_dir, shared.cmd_opts.lyco_dir_backcompat]
def create_user_metadata_editor(self, ui, tabname):
return LoraUserMetadataEditor(ui, tabname, self)
Import
from ui_extra_networks_lora import ExtraNetworksPageLora
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| name | str | Yes (create_item) | The registered name of the network in networks.available_networks
|
| index | int or None | No | Positional index used as default sort key |
| enable_filter | bool | No | When True (default), SD version compatibility filtering is applied |
Outputs
| Name | Type | Description |
|---|---|---|
| return (list_items) | Generator[dict, None, None] | Yields item dicts, one per compatible network |
| return (create_item) | dict or None | A dict with keys: name, filename, shorthash, preview, description, search_terms, local_preview, metadata, sort_keys, sd_version, prompt, negative_prompt; or None if filtered out |
Item dict structure:
| Key | Type | Description |
|---|---|---|
| name | str | Network name (filename stem) |
| filename | str | Full path to the network file on disk |
| shorthash | str | First 12 characters of SHA256 hash |
| preview | str or None | Path to preview image (sidecar or embedded) |
| description | str or None | Description text from sidecar file |
| search_terms | list[str] | Path-based search term and optional hash |
| local_preview | str | Path for saving generated preview images |
| metadata | dict | Safetensors training metadata |
| sort_keys | dict | Keys for UI sorting (default index, date, name, path) |
| sd_version | str | Detected SD version name (SD1, SD2, SDXL, Unknown) |
| prompt | str | JavaScript expression for prompt insertion: <lora:alias:weight>
|
| negative_prompt | str | JavaScript expression for negative prompt insertion |
Usage Examples
Basic Usage
# Instantiate the LoRA extra networks page
page = ExtraNetworksPageLora()
# Refresh the available networks list from disk
page.refresh()
# Iterate over all available and compatible LoRA items
for item in page.list_items():
print(f"Network: {item['name']}, Hash: {item['shorthash']}, Version: {item['sd_version']}")
Filtering Behavior
# create_item returns None for incompatible networks
# For example, with an SDXL model loaded:
item = page.create_item("sd1_lora_name", index=0, enable_filter=True)
# item is None because SD1 LoRA is incompatible with SDXL model
# Disable filtering to show all networks regardless of compatibility
item = page.create_item("sd1_lora_name", index=0, enable_filter=False)
# item is a dict with all network metadata