# How Extra Networks Work in AUTOMATIC1111: A Deep Dive into Checkpoints, Hypernetworks, and Textual Inversions

> Understand how extra networks work in AUTOMATIC1111 for image generation. Learn about checkpoints, hypernetworks, and textual inversions and how they integrate via prompt syntax and registry architecture.

- Repository: [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui)
- Tags: deep-dive
- Published: 2026-02-24

---

**Extra networks in AUTOMATIC1111 are a pluggable subsystem that allows users to inject checkpoints, hypernetworks, and textual inversion embeddings into image generation through a standardized registry architecture and prompt syntax parsing.**

The **extra networks** system provides a unified framework for extending Stable Diffusion generation capabilities without modifying the core model architecture. According to the AUTOMATIC1111 source code, this mechanism handles three distinct model-side extensions through a shared pipeline located primarily in [`modules/extra_networks.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/extra_networks.py).

## Understanding the Extra Networks Architecture

The entire extra networks ecosystem operates through an abstract base class pattern that separates parsing, registration, and activation concerns.

### The Core Registry System

At the heart of the system lies the **extra network registry**, a dictionary that maps textual identifiers to concrete `ExtraNetwork` implementations. When the WebUI launches, `register_default_extra_networks()` (lines 26-30 of [`modules/extra_networks.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/extra_networks.py)) populates this registry with built-in handlers, specifically registering `ExtraNetworkHypernet` for hypernetwork support.

Extensions can inject their own network types by calling `extra_networks.register_extra_network()`, passing an instance of a class that inherits from the base `ExtraNetwork` class. This registry pattern enables third-party extensions like LoRA and LyCORIS to hook into the same prompt parsing and activation flow as native features.

### Prompt Parsing Mechanics

Before generation begins, the `parse_prompt` function (lines 175-189 of [`modules/extra_networks.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/extra_networks.py)) scans user prompts using the regex pattern:

```python
re_extra_net = re.compile(r"<(\w+):([^>]+)>")

```

This pattern identifies angle-bracket tokens such as `<hypernet:my_model:1.2>` and splits them into network type and parameters. Each match instantiates an `ExtraNetworkParams` object containing the positional arguments as a list of strings in the `items` attribute.

## How Each Extra Network Type Works

The three primary extra network implementations each handle distinct model artifacts through specialized activation logic.

### Hyper-Networks (`<hypernet:name:multiplier>`)

Hyper-networks utilize the syntax `<hypernet:name:multiplier>` to load secondary neural networks that modify the primary model's weights during inference. When `activate(p, extra_network_data)` processes hypernetwork parameters, it invokes `ExtraNetworkHypernet.activate` (defined in [`modules/extra_networks_hypernet.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/extra_networks_hypernet.py)).

The activation sequence:

1. Extracts names and multipliers from `ExtraNetworkParams.items`
2. Calls `hypernetwork.load_hypernetworks(names, multipliers)` to load weights (lines 25-26)
3. Appends a default hypernetwork if `shared.opts.sd_hypernetwork` is configured (lines 10-16)

```python

# User prompt example

prompt = "portrait, <hypernet:my_hypernet:1.2>"

# Internal activation flow

extra_data = {'hypernet': [ExtraNetworkParams(items=['my_hypernet', '1.2'])]}
extra_networks.activate(p, extra_data)

# Results in: hypernetwork.load_hypernetworks(['my_hypernet'], [1.2])

```

### Textual Inversions (Embedding Names)

Unlike hypernetworks, **textual inversions** do not require angle-bracket syntax in the final prompt. Instead, the UI page `ExtraNetworksPageTextualInversion` (in [`modules/ui_extra_networks_textual_inversion.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/ui_extra_networks_textual_inversion.py)) inserts the embedding name directly into the prompt text when a user clicks a card.

The `create_item` method (lines 20-33) generates card metadata including:

```python
item = {
    "name": "my_embedding",
    "prompt": quote_js("my_embedding"),  # Line 31

    # ... preview image and description

}

```

The diffusion backend automatically recognizes these embeddings through `sd_hijack.model_hijack.embedding_db`, which loads textual inversion files when the model initializes. No explicit activation step occurs in [`extra_networks.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/extra_networks.py) because the tokenizer handles embedding resolution internally.

### Checkpoints (Model Swapping)

The **checkpoints** tab operates differently from other extra networks. Located in [`modules/ui_extra_networks_checkpoints.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/ui_extra_networks_checkpoints.py), this implementation swaps the base Stable Diffusion model via `sd_models` when a user selects a checkpoint card.

Because the model swap occurs before the generation pipeline begins, the checkpoint extra network's `activate` method is effectively a no-op. The registry entry exists primarily for UI consistency and metadata management rather than runtime weight manipulation.

## The Activation and Deactivation Lifecycle

The generation process follows a strict lifecycle managed by [`modules/extra_networks.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/extra_networks.py):

1. **Pre-generation**: `activate(p, extra_network_data)` (lines 26-48) iterates through the registry, calling each network's `activate()` method with its corresponding parameters
2. **Inference**: The diffusion process runs with modified weights, embeddings, or base models
3. **Post-generation**: `deactivate(p, extra_network_data)` (lines 53-73) invokes each network's `deactivate()` method to clean up state

For hypernetworks, the `deactivate` method is a stub (`pass`) because the system automatically clears hypernetwork state when loading the next model. This design prevents memory leaks while minimizing boilerplate for network implementations that require cleanup.

## UI Integration and Card Rendering

The visual interface for extra networks lives in [`modules/ui_extra_networks.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/ui_extra_networks.py), where the `ExtraNetworksPage` class (lines 186-345) defines generic card rendering, search functionality, and prompt insertion logic.

Specialized subclasses implement type-specific metadata:

- `ExtraNetworksPageHypernetworks` → [`modules/ui_extra_networks_hypernets.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/ui_extra_networks_hypernets.py)
- `ExtraNetworksPageTextualInversion` → [`modules/ui_extra_networks_textual_inversion.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/ui_extra_networks_textual_inversion.py)
- `ExtraNetworksPageCheckpoints` → [`modules/ui_extra_networks_checkpoints.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/ui_extra_networks_checkpoints.py)

The main UI controller ([`modules/ui.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/ui.py), lines 494-505) injects these components into both the **Txt2Img** and **Img2Img** tabs using:

```python
ui_extra_networks.create_ui(...)
ui_extra_networks.setup_ui(...)

```

User-configurable defaults reside in [`modules/shared_options.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/shared_options.py) (lines 274-290), including the `extra_networks_default_multiplier` setting that controls the default strength when hypernetworks are added automatically.

## Extending Extra Networks with Custom Implementations

Developers can register custom extra network types by subclassing `ExtraNetwork` and implementing the activation interface. The following pattern demonstrates registering a hypothetical LoRA implementation:

```python

# my_lora.py

from modules import extra_networks, shared

class ExtraNetworkLoRA(extra_networks.ExtraNetwork):
    def __init__(self):
        super().__init__('lora')

    def activate(self, p, params_list):
        for params in params_list:
            name = params.items[0]
            weight = float(params.items[1]) if len(params.items) > 1 else 1.0
            shared.loras.load_lora(name, weight)

    def deactivate(self, p):
        shared.loras.unload_all()

# Registration during launch

from my_lora import ExtraNetworkLoRA
extra_networks.register_extra_network(ExtraNetworkLoRA())

```

This follows the same registration pattern used by `register_default_extra_networks()` in the core codebase.

## Summary

- **Extra networks** provide a standardized registry-based architecture for extending generation capabilities through [`modules/extra_networks.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/extra_networks.py)
- **Prompt parsing** uses regex `r"<(\w+):([^>]+)>"` to identify network tokens and convert them into `ExtraNetworkParams` objects
- **Hypernetworks** load via `load_hypernetworks()` with multipliers, while **textual inversions** rely on tokenizer embedding lookup and **checkpoints** swap the base model pre-generation
- **Activation and deactivation** hooks allow networks to modify processing state before inference and clean up afterward
- **UI pages** inherit from `ExtraNetworksPage` to provide consistent card-based interfaces across all network types
- **Extensions** can register new network types by subclassing `ExtraNetwork` and calling `register_extra_network()`

## Frequently Asked Questions

### What is the syntax for using hypernetworks in prompts?

Hypernetworks use the syntax `<hypernet:name:multiplier>` where `name` corresponds to the file in your hypernetworks directory and `multiplier` controls the strength (typically 0.0 to 1.0 or higher). For example, `<hypernet:anime_style:0.8>` applies the "anime_style" hypernetwork at 80% strength. The parser extracts these values into an `ExtraNetworkParams` instance with `items=['anime_style', '0.8']`.

### How do textual inversions differ from hypernetworks in implementation?

Textual inversions differ fundamentally in their injection mechanism. While hypernetworks require explicit activation through [`extra_networks_hypernet.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/extra_networks_hypernet.py) to load weight matrices, textual inversions are simply words inserted into the prompt that match keys in `sd_hijack.model_hijack.embedding_db`. The tokenizer automatically substitutes these words with learned embedding vectors, requiring no runtime activation logic in the extra networks pipeline.

### Can I create custom extra network types for AUTOMATIC1111?

Yes, the architecture supports custom implementations through the `ExtraNetwork` abstract base class. Create a subclass implementing `activate(p, params_list)` and optionally `deactivate(p)`, then register it using `extra_networks.register_extra_network()`. This pattern enables extensions like LoRA and LyCORIS to integrate seamlessly with the native UI cards and prompt syntax.

### Where are extra network settings configured?

Default settings for extra networks reside in **Settings → Extra Networks** within the WebUI interface. These options are defined in [`modules/shared_options.py`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/main/modules/shared_options.py) between lines 274-290, including the `extra_networks_default_multiplier` parameter that sets the default strength for hypernetworks added through the UI rather than manual prompt entry.