Instructions to use Wayne-King/echo-memory-diffusers with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use Wayne-King/echo-memory-diffusers with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("Wayne-King/echo-memory-diffusers", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Upload pipeline.py with huggingface_hub
Browse files- pipeline.py +23 -4
pipeline.py
CHANGED
|
@@ -18,6 +18,9 @@ Loads `Wan-AI/Wan2.1-T2V-1.3B-Diffusers`, then overlays the released
|
|
| 18 |
`context_k1` row from `Echo-Team/Echo-Memory` after remapping original
|
| 19 |
DiffSynth / Wan keys onto the Diffusers transformer.
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
Paper: https://arxiv.org/abs/2606.09803
|
| 22 |
Code: https://github.com/Echo-Team-Joy-Future-Academy-JD/Echo-Memory
|
| 23 |
"""
|
|
@@ -29,7 +32,10 @@ from huggingface_hub import hf_hub_download
|
|
| 29 |
from safetensors.torch import load_file
|
| 30 |
|
| 31 |
from diffusers import WanPipeline
|
|
|
|
|
|
|
| 32 |
|
|
|
|
| 33 |
|
| 34 |
DEFAULT_BASE_MODEL = "Wan-AI/Wan2.1-T2V-1.3B-Diffusers"
|
| 35 |
DEFAULT_REPO_ID = "Echo-Team/Echo-Memory"
|
|
@@ -46,6 +52,7 @@ SKIP_SUBSTRINGS = (
|
|
| 46 |
)
|
| 47 |
|
| 48 |
# Same mapping as `scripts/convert_wan_to_diffusers.py` for Wan 2.1 T2V.
|
|
|
|
| 49 |
TRANSFORMER_KEYS_RENAME_DICT = {
|
| 50 |
"time_embedding.0": "condition_embedder.time_embedder.linear_1",
|
| 51 |
"time_embedding.2": "condition_embedder.time_embedder.linear_2",
|
|
@@ -111,7 +118,11 @@ def convert_echo_memory_transformer_state_dict(
|
|
| 111 |
|
| 112 |
|
| 113 |
class EchoMemoryPipeline(WanPipeline):
|
| 114 |
-
"""Wan 2.1 T2V pipeline with an Echo-Memory `context_k1` overlay.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
def load_echo_memory_weights(
|
| 117 |
self,
|
|
@@ -121,13 +132,21 @@ class EchoMemoryPipeline(WanPipeline):
|
|
| 121 |
strict: bool = False,
|
| 122 |
):
|
| 123 |
"""Download one Echo-Memory row and overlay it on `self.transformer`."""
|
|
|
|
|
|
|
|
|
|
| 124 |
ckpt_path = local_path or hf_hub_download(repo_id=repo_id, filename=filename)
|
| 125 |
raw = load_file(ckpt_path)
|
| 126 |
converted, skipped = convert_echo_memory_transformer_state_dict(raw)
|
| 127 |
missing, unexpected = self.transformer.load_state_dict(converted, strict=strict)
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
)
|
| 132 |
return missing, unexpected, skipped
|
| 133 |
|
|
|
|
| 18 |
`context_k1` row from `Echo-Team/Echo-Memory` after remapping original
|
| 19 |
DiffSynth / Wan keys onto the Diffusers transformer.
|
| 20 |
|
| 21 |
+
This is a community overlay, not a new official Wan checkpoint. Extra
|
| 22 |
+
action-MLP / SSM slots stay in the Echo-Memory research stack.
|
| 23 |
+
|
| 24 |
Paper: https://arxiv.org/abs/2606.09803
|
| 25 |
Code: https://github.com/Echo-Team-Joy-Future-Academy-JD/Echo-Memory
|
| 26 |
"""
|
|
|
|
| 32 |
from safetensors.torch import load_file
|
| 33 |
|
| 34 |
from diffusers import WanPipeline
|
| 35 |
+
from diffusers.utils import logging
|
| 36 |
+
|
| 37 |
|
| 38 |
+
logger = logging.get_logger(__name__) # pylint: disable=invalid-name
|
| 39 |
|
| 40 |
DEFAULT_BASE_MODEL = "Wan-AI/Wan2.1-T2V-1.3B-Diffusers"
|
| 41 |
DEFAULT_REPO_ID = "Echo-Team/Echo-Memory"
|
|
|
|
| 52 |
)
|
| 53 |
|
| 54 |
# Same mapping as `scripts/convert_wan_to_diffusers.py` for Wan 2.1 T2V.
|
| 55 |
+
# Duplicated here because that script is not an importable package.
|
| 56 |
TRANSFORMER_KEYS_RENAME_DICT = {
|
| 57 |
"time_embedding.0": "condition_embedder.time_embedder.linear_1",
|
| 58 |
"time_embedding.2": "condition_embedder.time_embedder.linear_2",
|
|
|
|
| 118 |
|
| 119 |
|
| 120 |
class EchoMemoryPipeline(WanPipeline):
|
| 121 |
+
"""Wan 2.1 T2V pipeline with an Echo-Memory `context_k1` overlay.
|
| 122 |
+
|
| 123 |
+
`load_echo_memory_weights` replaces `self.transformer` parameters in place.
|
| 124 |
+
Call it once after `from_pretrained`, before generation.
|
| 125 |
+
"""
|
| 126 |
|
| 127 |
def load_echo_memory_weights(
|
| 128 |
self,
|
|
|
|
| 132 |
strict: bool = False,
|
| 133 |
):
|
| 134 |
"""Download one Echo-Memory row and overlay it on `self.transformer`."""
|
| 135 |
+
if getattr(self, "transformer", None) is None:
|
| 136 |
+
raise ValueError("pipeline.transformer is empty; load Wan 2.1 1.3B before overlaying Echo-Memory.")
|
| 137 |
+
|
| 138 |
ckpt_path = local_path or hf_hub_download(repo_id=repo_id, filename=filename)
|
| 139 |
raw = load_file(ckpt_path)
|
| 140 |
converted, skipped = convert_echo_memory_transformer_state_dict(raw)
|
| 141 |
missing, unexpected = self.transformer.load_state_dict(converted, strict=strict)
|
| 142 |
+
logger.info(
|
| 143 |
+
"Overlaid %s/%s transformer keys from %s (skipped=%s, missing=%s, unexpected=%s)",
|
| 144 |
+
len(converted),
|
| 145 |
+
len(raw),
|
| 146 |
+
ckpt_path,
|
| 147 |
+
len(skipped),
|
| 148 |
+
len(missing),
|
| 149 |
+
len(unexpected),
|
| 150 |
)
|
| 151 |
return missing, unexpected, skipped
|
| 152 |
|