mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-28 11:53:04 +08:00
Compare commits
3 Commits
feat/api-n
...
feat/load3
| Author | SHA1 | Date | |
|---|---|---|---|
| f29e27f8f9 | |||
| 987a937658 | |||
| 51ef17e8a6 |
@ -207,8 +207,9 @@ class PidNet(PixDiT_T2I):
|
||||
f"Flux1/SD3 = 16 channels, Flux2 = 128 channels."
|
||||
)
|
||||
B = x.shape[0]
|
||||
Hs = x.shape[2] // self.patch_size
|
||||
Ws = x.shape[3] // self.patch_size
|
||||
# Match the backbone's pad_to_patch_size (round up) so the LQ grid lines up with the patch stream.
|
||||
Hs = -(-x.shape[2] // self.patch_size)
|
||||
Ws = -(-x.shape[3] // self.patch_size)
|
||||
|
||||
degrade_sigma = degrade_sigma.to(device=x.device, dtype=torch.float32).reshape(-1)
|
||||
if degrade_sigma.numel() == 1 and B > 1:
|
||||
|
||||
@ -1428,6 +1428,23 @@ class PiD(PixelDiTT2I):
|
||||
out["degrade_sigma"] = comfy.conds.CONDRegular(degrade_sigma)
|
||||
return out
|
||||
|
||||
def resize_cond_for_context_window(self, cond_key, cond_value, window, x_in, device, retain_index_list=[]):
|
||||
if cond_key == "lq_latent" and hasattr(cond_value, "cond") and isinstance(cond_value.cond, torch.Tensor):
|
||||
lq = cond_value.cond
|
||||
dim = window.dim
|
||||
if dim >= lq.ndim:
|
||||
return None
|
||||
lq_proj = self.diffusion_model.lq_proj
|
||||
ratio = lq_proj.sr_scale * lq_proj.latent_spatial_down_factor
|
||||
# Map x window indices -> lq indices (deduplicated, sorted, in-bounds).
|
||||
lq_size = lq.size(dim)
|
||||
lq_indices = sorted({i // ratio for i in window.index_list if 0 <= i // ratio < lq_size})
|
||||
if not lq_indices:
|
||||
return None
|
||||
idx = tuple([slice(None)] * dim + [lq_indices])
|
||||
return cond_value._copy_with(lq[idx].to(device))
|
||||
return super().resize_cond_for_context_window(cond_key, cond_value, window, x_in, device, retain_index_list=retain_index_list)
|
||||
|
||||
|
||||
class WAN21(BaseModel):
|
||||
def __init__(self, model_config, model_type=ModelType.FLOW, image_to_video=False, device=None):
|
||||
|
||||
@ -770,6 +770,23 @@ class Load3DCamera(ComfyTypeIO):
|
||||
Type = CameraInfo
|
||||
|
||||
|
||||
@comfytype(io_type="LOAD3D_MODEL_INFO")
|
||||
class Load3DModelInfo(ComfyTypeIO):
|
||||
class ModelTransform(TypedDict):
|
||||
uuid: str
|
||||
name: str
|
||||
type: str
|
||||
position: dict[str, float | int]
|
||||
rotation: dict[str, float | int | str]
|
||||
quaternion: dict[str, float | int]
|
||||
scale: dict[str, float | int]
|
||||
up: dict[str, float | int]
|
||||
visible: bool
|
||||
matrix: list[float]
|
||||
|
||||
Type = list[ModelTransform]
|
||||
|
||||
|
||||
@comfytype(io_type="LOAD_3D")
|
||||
class Load3D(ComfyTypeIO):
|
||||
"""3D models are stored as a dictionary."""
|
||||
@ -779,6 +796,7 @@ class Load3D(ComfyTypeIO):
|
||||
normal: str
|
||||
camera_info: Load3DCamera.CameraInfo
|
||||
recording: NotRequired[str]
|
||||
model_info: NotRequired[list[Load3DModelInfo.ModelTransform]]
|
||||
|
||||
Type = Model3DDict
|
||||
|
||||
@ -2291,6 +2309,7 @@ __all__ = [
|
||||
"FlowControl",
|
||||
"Accumulation",
|
||||
"Load3DCamera",
|
||||
"Load3DModelInfo",
|
||||
"Load3D",
|
||||
"Load3DAnimation",
|
||||
"Photomaker",
|
||||
|
||||
@ -47,6 +47,7 @@ class Load3D(IO.ComfyNode):
|
||||
IO.Load3DCamera.Output(display_name="camera_info"),
|
||||
IO.Video.Output(display_name="recording_video"),
|
||||
IO.File3DAny.Output(display_name="model_3d"),
|
||||
IO.Load3DModelInfo.Output(display_name="model_info"),
|
||||
],
|
||||
)
|
||||
|
||||
@ -69,7 +70,8 @@ class Load3D(IO.ComfyNode):
|
||||
video = InputImpl.VideoFromFile(recording_video_path)
|
||||
|
||||
file_3d = Types.File3D(folder_paths.get_annotated_filepath(model_file))
|
||||
return IO.NodeOutput(output_image, output_mask, model_file, normal_image, image['camera_info'], video, file_3d)
|
||||
model_info = image.get('model_info', [])
|
||||
return IO.NodeOutput(output_image, output_mask, model_file, normal_image, image['camera_info'], video, file_3d, model_info)
|
||||
|
||||
process = execute # TODO: remove
|
||||
|
||||
|
||||
Reference in New Issue
Block a user