mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-21 23:27:06 +08:00
Fix model patcher types
This commit is contained in:
parent
58c9838274
commit
ddd2ac967c
@ -6,7 +6,7 @@ import uuid
|
|||||||
|
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
import comfy.model_management
|
import comfy.model_management
|
||||||
from comfy.types import UnetWrapperFunction
|
from comfy.model_patcher_types import UnetWrapperFunction
|
||||||
|
|
||||||
|
|
||||||
def apply_weight_decompose(dora_scale, weight):
|
def apply_weight_decompose(dora_scale, weight):
|
||||||
|
|||||||
36
comfy/model_patcher_types.py
Normal file
36
comfy/model_patcher_types.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Callable, Protocol, TypedDict, List
|
||||||
|
from typing_extensions import NotRequired
|
||||||
|
|
||||||
|
import torch
|
||||||
|
|
||||||
|
|
||||||
|
class UnetApplyFunction(Protocol):
|
||||||
|
"""Function signature protocol on comfy.model_base.BaseModel.apply_model"""
|
||||||
|
|
||||||
|
def __call__(self, x: torch.Tensor, t: torch.Tensor, **kwargs) -> torch.Tensor:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UnetApplyConds(TypedDict):
|
||||||
|
"""Optional conditions for unet apply function."""
|
||||||
|
|
||||||
|
c_concat: NotRequired[torch.Tensor]
|
||||||
|
c_crossattn: NotRequired[torch.Tensor]
|
||||||
|
control: NotRequired[torch.Tensor]
|
||||||
|
transformer_options: NotRequired[dict]
|
||||||
|
|
||||||
|
|
||||||
|
class UnetParams(TypedDict):
|
||||||
|
# Tensor of shape [B, C, H, W]
|
||||||
|
input: torch.Tensor
|
||||||
|
# Tensor of shape [B]
|
||||||
|
timestep: torch.Tensor
|
||||||
|
c: UnetApplyConds
|
||||||
|
# List of [0, 1], [0], [1], ...
|
||||||
|
# 0 means unconditional, 1 means conditional
|
||||||
|
cond_or_uncond: List[int]
|
||||||
|
|
||||||
|
|
||||||
|
UnetWrapperFunction = Callable[[UnetApplyFunction, UnetParams], torch.Tensor]
|
||||||
Loading…
x
Reference in New Issue
Block a user