diffusers-workflow 0.4.0a3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- diffusers_workflow-0.4.0a3.dist-info/METADATA +310 -0
- diffusers_workflow-0.4.0a3.dist-info/RECORD +171 -0
- diffusers_workflow-0.4.0a3.dist-info/WHEEL +5 -0
- diffusers_workflow-0.4.0a3.dist-info/entry_points.txt +6 -0
- diffusers_workflow-0.4.0a3.dist-info/licenses/LICENSE +201 -0
- diffusers_workflow-0.4.0a3.dist-info/top_level.txt +1 -0
- dw/__init__.py +353 -0
- dw/arguments.py +906 -0
- dw/cache_blocks.json +16 -0
- dw/cache_blocks.py +145 -0
- dw/community_pipelines/pipeline_flux_rf_inversion.py +1184 -0
- dw/events.py +78 -0
- dw/hub_cache.py +289 -0
- dw/introspection.py +458 -0
- dw/log_setup.py +45 -0
- dw/pipeline_processors/chain.py +750 -0
- dw/pipeline_processors/config_objects.py +235 -0
- dw/pipeline_processors/pipeline.py +1687 -0
- dw/pipeline_processors/remote.py +18 -0
- dw/previous_results.py +259 -0
- dw/prompt_weighting.py +378 -0
- dw/repl.py +298 -0
- dw/repl_commands.py +808 -0
- dw/repl_worker.py +129 -0
- dw/result.py +850 -0
- dw/run.py +92 -0
- dw/schema.py +24 -0
- dw/security.py +379 -0
- dw/serve.py +70 -0
- dw/server/__init__.py +2 -0
- dw/server/app.py +588 -0
- dw/server/jobs.py +547 -0
- dw/server/ui/assets/abap-08VXUWAP.js +1 -0
- dw/server/ui/assets/apex-BWPQTe0t.js +1 -0
- dw/server/ui/assets/azcli-Bc_sGQ0U.js +1 -0
- dw/server/ui/assets/bat-i0X4ZdIN.js +1 -0
- dw/server/ui/assets/bicep-B5-_aFwp.js +2 -0
- dw/server/ui/assets/cameligo-DMUM7wLl.js +1 -0
- dw/server/ui/assets/clojure-Cm7r79vr.js +1 -0
- dw/server/ui/assets/codicon-Brq4_Ui5.ttf +0 -0
- dw/server/ui/assets/coffee-Ba7i2nA0.js +1 -0
- dw/server/ui/assets/cpp-C7h46wYY.js +1 -0
- dw/server/ui/assets/csharp-BKxtCVv1.js +1 -0
- dw/server/ui/assets/csp-bTuwJoIa.js +1 -0
- dw/server/ui/assets/css-DIMkf-bt.js +3 -0
- dw/server/ui/assets/css.worker-B3ciXF_0.js +93 -0
- dw/server/ui/assets/cssMode-CEh6hWi2.js +1 -0
- dw/server/ui/assets/cypher-CVaqCwHa.js +1 -0
- dw/server/ui/assets/dart-onAF5SnQ.js +1 -0
- dw/server/ui/assets/dockerfile-DZFCIeNp.js +1 -0
- dw/server/ui/assets/ecl-D05T4iGw.js +1 -0
- dw/server/ui/assets/editor-jjEx9u7D.css +1 -0
- dw/server/ui/assets/editor.api-CExg3_mM.js +847 -0
- dw/server/ui/assets/editor.worker-q-txB4vs.js +30 -0
- dw/server/ui/assets/elixir-6RTg0lbw.js +1 -0
- dw/server/ui/assets/flow9-C5_-GSwl.js +1 -0
- dw/server/ui/assets/freemarker2-DH6orYh2.js +3 -0
- dw/server/ui/assets/fsharp-C8Ef5oNN.js +1 -0
- dw/server/ui/assets/go-C-y9NEjX.js +1 -0
- dw/server/ui/assets/graphql-fmXr3nnJ.js +1 -0
- dw/server/ui/assets/handlebars-CbrMVW4Q.js +1 -0
- dw/server/ui/assets/hcl-CpzslTdj.js +1 -0
- dw/server/ui/assets/html-YDNPZw2M.js +1 -0
- dw/server/ui/assets/html.worker-C93Ht9o9.js +506 -0
- dw/server/ui/assets/htmlMode-B_zSGWO2.js +1 -0
- dw/server/ui/assets/index-B7-VcYS-.css +1 -0
- dw/server/ui/assets/index-D_EiPU3b.js +13 -0
- dw/server/ui/assets/ini-sBoK_t0W.js +1 -0
- dw/server/ui/assets/java-BEtHBSE6.js +1 -0
- dw/server/ui/assets/javascript-dYuBvioq.js +1 -0
- dw/server/ui/assets/json.worker-B2V3pomh.js +62 -0
- dw/server/ui/assets/jsonMode-CUqLM39V.js +7 -0
- dw/server/ui/assets/julia-Bri6UV-V.js +1 -0
- dw/server/ui/assets/kotlin-BOotOW0E.js +1 -0
- dw/server/ui/assets/less-B9JPFI3C.js +2 -0
- dw/server/ui/assets/lexon-CfSJPG6W.js +1 -0
- dw/server/ui/assets/liquid-D6vxBzMv.js +1 -0
- dw/server/ui/assets/lspLanguageFeatures-1WJ2palX.js +4 -0
- dw/server/ui/assets/lua-CsQS60Ue.js +1 -0
- dw/server/ui/assets/m3-D-oSqn_W.js +1 -0
- dw/server/ui/assets/markdown-Cimd5fb3.js +1 -0
- dw/server/ui/assets/mdx-SHQb6vmD.js +1 -0
- dw/server/ui/assets/mips-CIPQ_RoX.js +1 -0
- dw/server/ui/assets/monaco--ixms01u.css +1 -0
- dw/server/ui/assets/monaco-CP-s5rcP.js +56 -0
- dw/server/ui/assets/msdax-DauUninz.js +1 -0
- dw/server/ui/assets/mysql-SOo6toE5.js +1 -0
- dw/server/ui/assets/objective-c-FvmIjYaQ.js +1 -0
- dw/server/ui/assets/pascal-DrH0SRf2.js +1 -0
- dw/server/ui/assets/pascaligo-D-ptJ9y-.js +1 -0
- dw/server/ui/assets/perl-oz_6vUea.js +1 -0
- dw/server/ui/assets/pgsql-DTj74zXo.js +1 -0
- dw/server/ui/assets/php-nr791fC2.js +1 -0
- dw/server/ui/assets/pla-CopQ2nXW.js +1 -0
- dw/server/ui/assets/postiats-43DmfD33.js +1 -0
- dw/server/ui/assets/powerquery-D3hlyOfw.js +1 -0
- dw/server/ui/assets/powershell-DmHpPYUd.js +1 -0
- dw/server/ui/assets/protobuf-C531GsRP.js +2 -0
- dw/server/ui/assets/pug-Z5eAx3Zn.js +1 -0
- dw/server/ui/assets/python-x0_EGHq9.js +1 -0
- dw/server/ui/assets/qsharp-DkqhCAOL.js +1 -0
- dw/server/ui/assets/r-BwWrilGY.js +1 -0
- dw/server/ui/assets/razor-BZC4LQDP.js +1 -0
- dw/server/ui/assets/redis-ClamHrr6.js +1 -0
- dw/server/ui/assets/redshift-DT7zqm-g.js +1 -0
- dw/server/ui/assets/restructuredtext-BYgofb2h.js +1 -0
- dw/server/ui/assets/ruby-DezsRK8O.js +1 -0
- dw/server/ui/assets/rust-DdL9SqIa.js +1 -0
- dw/server/ui/assets/sb-CcwsVR0C.js +1 -0
- dw/server/ui/assets/scala-DHpiXF5c.js +1 -0
- dw/server/ui/assets/scheme-BeGwcela.js +1 -0
- dw/server/ui/assets/scss-gp-XZpBa.js +3 -0
- dw/server/ui/assets/shell-CC2rA5mh.js +1 -0
- dw/server/ui/assets/solidity-BEEn4gHE.js +1 -0
- dw/server/ui/assets/sophia-CRfGWb83.js +1 -0
- dw/server/ui/assets/sparql-D_Lu-MrJ.js +1 -0
- dw/server/ui/assets/sql-NEE52Syq.js +1 -0
- dw/server/ui/assets/st-DbInun42.js +1 -0
- dw/server/ui/assets/swift-Bxkupp3x.js +1 -0
- dw/server/ui/assets/systemverilog-Bz4Y3fRF.js +1 -0
- dw/server/ui/assets/tcl-DISqw1ZD.js +1 -0
- dw/server/ui/assets/ts.worker-D7T1-Ig5.js +67738 -0
- dw/server/ui/assets/tsMode-BTfA6SbD.js +11 -0
- dw/server/ui/assets/twig-De2hgUGE.js +1 -0
- dw/server/ui/assets/typescript-CWA4MsNk.js +1 -0
- dw/server/ui/assets/typespec-B8J7ngcE.js +1 -0
- dw/server/ui/assets/vb-DV3o63ZY.js +1 -0
- dw/server/ui/assets/wgsl-DpFanUEy.js +298 -0
- dw/server/ui/assets/workers-CWU0uvj5.js +1 -0
- dw/server/ui/assets/xml-KmfTm3rg.js +1 -0
- dw/server/ui/assets/yaml-nFO_dDS6.js +1 -0
- dw/server/ui/index.html +17 -0
- dw/settings.py +77 -0
- dw/step.py +132 -0
- dw/tasks/audio_utils.py +266 -0
- dw/tasks/background_remover.py +43 -0
- dw/tasks/borders.py +113 -0
- dw/tasks/concat_videos.py +80 -0
- dw/tasks/depth_estimator.py +54 -0
- dw/tasks/diffusion_upscale.py +109 -0
- dw/tasks/format_messages.py +24 -0
- dw/tasks/gather.py +139 -0
- dw/tasks/image_to_text.py +43 -0
- dw/tasks/image_utils.py +661 -0
- dw/tasks/interpolate_frames.py +227 -0
- dw/tasks/model_cache.py +39 -0
- dw/tasks/pair_audio.py +58 -0
- dw/tasks/qr_code.py +19 -0
- dw/tasks/restore_faces.py +175 -0
- dw/tasks/rife_model.py +192 -0
- dw/tasks/segment.py +121 -0
- dw/tasks/task.py +474 -0
- dw/tasks/tensor_image.py +57 -0
- dw/tasks/text_generation.py +168 -0
- dw/tasks/text_sections.py +80 -0
- dw/tasks/upscale.py +203 -0
- dw/tasks/video_utils.py +154 -0
- dw/tasks/zoe_depth.py +71 -0
- dw/teacache.py +376 -0
- dw/teacache_models.json +99 -0
- dw/test.py +29 -0
- dw/type_helpers.py +68 -0
- dw/validate.py +43 -0
- dw/variables.py +153 -0
- dw/worker.py +517 -0
- dw/workflow.py +553 -0
- dw/workflow_schema.json +1157 -0
- dw/workflows/augment_prompt.json +65 -0
- dw/workflows/describe_image.json +58 -0
- dw/workflows/h3_context_ir.json +57 -0
- dw/workflows/test.json +31 -0
dw/cache_blocks.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "Transformer block metadata for diffusers' cache hooks. first_block, mag and layer_skip look their block class up in diffusers.hooks._helpers.TransformerBlockRegistry and raise if it is missing. Blocks listed here are registered on demand so those cache types work on models diffusers has not registered upstream. Fields mirror diffusers.hooks._helpers.TransformerBlockMetadata, plus dw's own encoder_hidden_states_argument_name. Verify against the block's forward before adding an entry: return_hidden_states_index is the position of hidden_states in the returned tuple, and is ignored when the block returns a bare tensor; return_encoder_hidden_states_index is null when the block does not return a second stream; hidden_states_argument_name must name the forward parameter carrying hidden_states; encoder_hidden_states_argument_name names the forward parameter the second returned stream comes from, and is only needed when that is not literally 'encoder_hidden_states' - see dw/cache_blocks.py.",
|
|
3
|
+
"blocks": {
|
|
4
|
+
"diffusers.models.transformers.transformer_minimax_h3.MiniMaxH3TransformerBlock": {
|
|
5
|
+
"return_hidden_states_index": 0,
|
|
6
|
+
"return_encoder_hidden_states_index": null,
|
|
7
|
+
"hidden_states_argument_name": "hidden_states"
|
|
8
|
+
},
|
|
9
|
+
"diffusers.models.transformers.transformer_ltx2.LTX2VideoTransformerBlock": {
|
|
10
|
+
"return_hidden_states_index": 0,
|
|
11
|
+
"return_encoder_hidden_states_index": 1,
|
|
12
|
+
"hidden_states_argument_name": "hidden_states",
|
|
13
|
+
"encoder_hidden_states_argument_name": "audio_hidden_states"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
dw/cache_blocks.py
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""Register transformer block metadata diffusers' cache hooks are missing.
|
|
2
|
+
|
|
3
|
+
The first_block, mag and layer_skip cache types look a model's transformer block
|
|
4
|
+
class up in diffusers.hooks._helpers.TransformerBlockRegistry and raise
|
|
5
|
+
ValueError when it is absent, so those caches are unavailable on any model
|
|
6
|
+
diffusers has not registered upstream - even though the model itself supports
|
|
7
|
+
enable_cache(). The blocks in cache_blocks.json fill that gap; entries become
|
|
8
|
+
redundant, not wrong, once diffusers registers the same class itself.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import logging
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
from .type_helpers import load_type_from_name
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger("dw")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
_REGISTRY_PATH = Path(__file__).parent / "cache_blocks.json"
|
|
21
|
+
|
|
22
|
+
# Registration walks every entry, so do it once rather than per pipeline load
|
|
23
|
+
_registered = False
|
|
24
|
+
|
|
25
|
+
# The registry field that is dw's own rather than one of TransformerBlockMetadata's -
|
|
26
|
+
# see _dual_stream_metadata_class for what it is for
|
|
27
|
+
ARGUMENT_REMAP_KEY = "encoder_hidden_states_argument_name"
|
|
28
|
+
|
|
29
|
+
# One subclass per metadata class, built on first use - the class it derives from
|
|
30
|
+
# only exists once diffusers has been imported
|
|
31
|
+
_dual_stream_classes = {}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _load_registry():
|
|
35
|
+
"""Load the block metadata registry from the JSON file."""
|
|
36
|
+
with open(_REGISTRY_PATH) as f:
|
|
37
|
+
return json.load(f).get("blocks", {})
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _dual_stream_metadata_class(metadata_class):
|
|
41
|
+
"""A metadata class that can name the block's second stream itself.
|
|
42
|
+
|
|
43
|
+
A block that returns two streams has the second one read back out of its
|
|
44
|
+
forward arguments when the cache skips it, and diffusers looks that argument
|
|
45
|
+
up under the fixed name 'encoder_hidden_states' - the only two-stream shape it
|
|
46
|
+
registers upstream is text beside image. LTX-2's blocks return video beside
|
|
47
|
+
*audio* while also taking an 'encoder_hidden_states' of their own (the text
|
|
48
|
+
conditioning), so the fixed name silently reads the wrong tensor and feeds the
|
|
49
|
+
text embeddings back as the audio stream. Remapping the identifier is what
|
|
50
|
+
makes first_block caching correct on those blocks rather than merely quiet.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
metadata_class: diffusers' TransformerBlockMetadata
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
A subclass reading the second stream from the argument the entry names
|
|
57
|
+
"""
|
|
58
|
+
if metadata_class not in _dual_stream_classes:
|
|
59
|
+
|
|
60
|
+
class DualStreamMetadata(metadata_class):
|
|
61
|
+
# Overridden per instance from the registry entry; the default keeps
|
|
62
|
+
# the class behaving exactly like the one it derives from
|
|
63
|
+
encoder_hidden_states_argument_name = "encoder_hidden_states"
|
|
64
|
+
|
|
65
|
+
def _get_parameter_from_args_kwargs(self, identifier, args=(), kwargs=None):
|
|
66
|
+
if identifier == "encoder_hidden_states":
|
|
67
|
+
identifier = self.encoder_hidden_states_argument_name
|
|
68
|
+
return super()._get_parameter_from_args_kwargs(identifier, args, kwargs)
|
|
69
|
+
|
|
70
|
+
_dual_stream_classes[metadata_class] = DualStreamMetadata
|
|
71
|
+
|
|
72
|
+
return _dual_stream_classes[metadata_class]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def build_metadata(metadata_class, entry):
|
|
76
|
+
"""Build the metadata object one registry entry describes.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
metadata_class: diffusers' TransformerBlockMetadata
|
|
80
|
+
entry: One block's fields from cache_blocks.json
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
An instance of metadata_class, or of the dual-stream subclass when the
|
|
84
|
+
entry names the argument its second returned stream comes from
|
|
85
|
+
"""
|
|
86
|
+
remapped = entry.get(ARGUMENT_REMAP_KEY)
|
|
87
|
+
fields = {k: v for k, v in entry.items() if k != ARGUMENT_REMAP_KEY}
|
|
88
|
+
|
|
89
|
+
if remapped is None:
|
|
90
|
+
return metadata_class(**fields)
|
|
91
|
+
|
|
92
|
+
metadata = _dual_stream_metadata_class(metadata_class)(**fields)
|
|
93
|
+
metadata.encoder_hidden_states_argument_name = remapped
|
|
94
|
+
return metadata
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def register_cache_blocks():
|
|
98
|
+
"""Register any known-missing transformer blocks with diffusers.
|
|
99
|
+
|
|
100
|
+
Safe to call repeatedly and before any cache type - blocks diffusers already
|
|
101
|
+
knows are left alone, and a block whose class the installed diffusers does
|
|
102
|
+
not have is skipped rather than raising.
|
|
103
|
+
"""
|
|
104
|
+
global _registered
|
|
105
|
+
if _registered:
|
|
106
|
+
return
|
|
107
|
+
|
|
108
|
+
try:
|
|
109
|
+
from diffusers.hooks._helpers import (
|
|
110
|
+
TransformerBlockMetadata,
|
|
111
|
+
TransformerBlockRegistry,
|
|
112
|
+
)
|
|
113
|
+
except ImportError:
|
|
114
|
+
# A diffusers without the cache hooks has nothing to register against
|
|
115
|
+
logger.debug(
|
|
116
|
+
"diffusers cache hook helpers unavailable, skipping block registration"
|
|
117
|
+
)
|
|
118
|
+
_registered = True
|
|
119
|
+
return
|
|
120
|
+
|
|
121
|
+
for class_name, metadata in _load_registry().items():
|
|
122
|
+
try:
|
|
123
|
+
block_class = load_type_from_name(class_name)
|
|
124
|
+
except (ImportError, AttributeError):
|
|
125
|
+
# The installed diffusers predates this model - its blocks are not
|
|
126
|
+
# missing from the registry, they do not exist
|
|
127
|
+
logger.debug(f"Cache block '{class_name}' not in this diffusers, skipping")
|
|
128
|
+
continue
|
|
129
|
+
|
|
130
|
+
# TransformerBlockRegistry.get raises rather than returning None, and an
|
|
131
|
+
# upstream registration is the more authoritative one either way
|
|
132
|
+
try:
|
|
133
|
+
TransformerBlockRegistry.get(block_class)
|
|
134
|
+
logger.debug(f"Cache block '{class_name}' already registered, leaving it")
|
|
135
|
+
continue
|
|
136
|
+
except ValueError:
|
|
137
|
+
pass
|
|
138
|
+
|
|
139
|
+
logger.debug(f"Registering cache block metadata for '{class_name}'")
|
|
140
|
+
TransformerBlockRegistry.register(
|
|
141
|
+
model_class=block_class,
|
|
142
|
+
metadata=build_metadata(TransformerBlockMetadata, metadata),
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
_registered = True
|