lllyasviel/ControlNet · error · ValueError

resize_method {self.__resize_method} not implemented

Error message

resize_method {self.__resize_method} not implemented

What it means

Raised by MiDaS Resize transform's get_size when the resize_method string is not one of the supported values. The transform computes new image size based on the configured strategy; an unknown strategy string falls through to this ValueError. Supported methods include upper_bound, lower_bound, and minimal.

Source

Thrown at annotator/midas/midas/transforms.py:136

                    scale_width = scale_height
            elif self.__resize_method == "upper_bound":
                # scale such that output size is upper bound
                if scale_width < scale_height:
                    # fit width
                    scale_height = scale_width
                else:
                    # fit height
                    scale_width = scale_height
            elif self.__resize_method == "minimal":
                # scale as least as possbile
                if abs(1 - scale_width) < abs(1 - scale_height):
                    # fit width
                    scale_height = scale_width
                else:
                    # fit height
                    scale_width = scale_height
            else:
                raise ValueError(
                    f"resize_method {self.__resize_method} not implemented"
                )

        if self.__resize_method == "lower_bound":
            new_height = self.constrain_to_multiple_of(
                scale_height * height, min_val=self.__height
            )
            new_width = self.constrain_to_multiple_of(
                scale_width * width, min_val=self.__width
            )
        elif self.__resize_method == "upper_bound":
            new_height = self.constrain_to_multiple_of(
                scale_height * height, max_val=self.__height
            )
            new_width = self.constrain_to_multiple_of(
                scale_width * width, max_val=self.__width
            )
        elif self.__resize_method == "minimal":

View on GitHub (pinned to ed85cd1e25)

Solutions

  1. Set resize_method to one of the supported strings: 'upper_bound', 'lower_bound', or 'minimal'
  2. Check the exact casing in your config file / constructor call against the midas transforms source
  3. If you need a custom method, subclass Resize and extend get_size instead of passing an unknown string

Example fix

# before
Resize(384, 384, resize_method='UpperBound')
# after
Resize(384, 384, resize_method='upper_bound')
Defensive patterns

Strategy: validation

Validate before calling

ALLOWED = {'upper_bound', 'lower_bound', 'minimal'}
assert resize_method in ALLOWED, f'resize_method must be one of {ALLOWED}'

Type guard

def is_valid_resize_method(m: str) -> bool:
    return isinstance(m, str) and m in {'upper_bound', 'lower_bound', 'minimal'}

Prevention

When it happens

Trigger: Instantiating annotator.midas.midas.transforms.Resize with resize_method set to a typo or unsupported string (e.g. 'Upper_bound', 'fit', 'crop'), then calling the transform on a sample (__call__ -> get_size).

Common situations: Copying a config from another repo/version where resize method names differ; typos in YAML/JSON config; custom forks adding methods not present in this copy of midas/transforms.py.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of lllyasviel/ControlNet@ed85cd1e25 (2026-08-27). Data as JSON: /api/errors/dfe07ddd29684999. Report an issue: GitHub.