Comfy-Org/ComfyUI · error · ValueError
Unsupported process_res_method: {method}
Error message
Unsupported process_res_method: {method} What it means
compute_target_size() chooses a resolution-scaling rule by method string: 'upper_bound_resize' (scale longest side to process_res) or 'lower_bound_resize' (scale shortest side). Any other string raises ValueError. Callers normally pass the default, so the error appears only when a custom method string is forwarded.
Source
Thrown at comfy/ldm/depth_anything_3/preprocess.py:36
def _round_to_patch(x: int, patch: int = PATCH_SIZE) -> int:
down = (x // patch) * patch
up = down + patch
return up if abs(up - x) <= abs(x - down) else down
def compute_target_size(orig_h: int, orig_w: int, process_res: int, method: str = "upper_bound_resize") -> Tuple[int, int]:
"""Compute (target_h, target_w) for a single image.
upper_bound_resize: scale longest side to process_res, then round each dim to nearest multiple of 14 (default upstream method).
lower_bound_resize: scale shortest side to process_res, then round."""
if method == "upper_bound_resize":
longest = max(orig_h, orig_w)
scale = process_res / float(longest)
elif method == "lower_bound_resize":
shortest = min(orig_h, orig_w)
scale = process_res / float(shortest)
else:
raise ValueError(f"Unsupported process_res_method: {method}")
new_w = max(1, _round_to_patch(int(round(orig_w * scale))))
new_h = max(1, _round_to_patch(int(round(orig_h * scale))))
return new_h, new_w
def preprocess_image(image: torch.Tensor, process_res: int = 504, method: str = "upper_bound_resize") -> torch.Tensor:
assert image.ndim == 4 and image.shape[-1] == 3, f"expected (B,H,W,3) IMAGE; got {tuple(image.shape)}"
B, H, W, _ = image.shape
target_h, target_w = compute_target_size(H, W, process_res, method)
# (B, H, W, 3) -> (B, 3, H, W)
x = image.movedim(-1, 1).contiguous()
if (target_h, target_w) != (H, W):
# Upstream uses cv2 INTER_CUBIC (upscale) / INTER_AREA (downscale).
# Lanczos in ``common_upscale`` is anti-aliased and produces the
# closest pixel-wise match in a sweep across {bilinear, bicubic,
# area, lanczos, bislerp}. Used in both directions for simplicity.View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Use "upper_bound_resize" (default) or "lower_bound_resize" exactly.
- If exposing the option in a node, make it a fixed combo of the two supported values rather than free text.
- Map/normalize any upstream method name to one of the two supported values at the node boundary.
Example fix
# before h, w = compute_target_size(H, W, 504, method="fit_longest") # after h, w = compute_target_size(H, W, 504, method="upper_bound_resize")
Defensive patterns
Strategy: type-guard
Validate before calling
assert method in ("upper_bound_resize", "lower_bound_resize"), f"unsupported method {method!r}" Type guard
def is_supported_resize_method(method: str) -> bool:
return method in {"upper_bound_resize", "lower_bound_resize"} Prevention
- Expose method options as a fixed combo/dropdown of the two supported values.
- Normalize upstream method names to this port's vocabulary at the boundary.
When it happens
Trigger: Calling preprocess_image()/compute_target_size() with method set to a value other than the two supported strings — e.g. a custom node exposing a free-text combo, or code copied from upstream that used a different method name like 'keep_aspect'.
Common situations: Custom nodes wrapping DA3 preprocessing with user-visible method dropdowns; drifting method names between upstream repo and this port.
Related errors
- At least 4 points are required to compute a homography.
- Unknown reference view selection strategy: {strategy!r}. Mus
- Unknown DINOv2 backbone variant: {backbone_name!r}
- Invalid affine shape: {ext.shape}
- Invalid rotation matrix shape {matrix.shape}.
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/763ed6625dbb85f9.
Report an issue: GitHub.