{"record":{"id":"c01da15412dc3906","repo":"huggingface/pytorch-image-models","slug":"range-should-be-of-kind-min-max","errorCode":null,"errorMessage":"range should be of kind (min, max)","messagePattern":"range should be of kind \\(min, max\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"timm/data/transforms.py","lineNumber":193,"sourceCode":"        size: expected output size of each edge\n        scale: range of size of the origin size cropped\n        ratio: range of aspect ratio of the origin aspect ratio cropped\n        interpolation: Default: PIL.Image.BILINEAR\n    \"\"\"\n\n    def __init__(\n            self,\n            size,\n            scale=(0.08, 1.0),\n            ratio=(3. / 4., 4. / 3.),\n            interpolation='bilinear',\n    ):\n        if isinstance(size, (list, tuple)):\n            self.size = tuple(size)\n        else:\n            self.size = (size, size)\n        if (scale[0] > scale[1]) or (ratio[0] > ratio[1]):\n            warnings.warn(\"range should be of kind (min, max)\")\n\n        if interpolation == 'random':\n            self.interpolation = _RANDOM_INTERPOLATION\n        else:\n            self.interpolation = str_to_interp_mode(interpolation)\n        self.scale = scale\n        self.ratio = ratio\n\n    @staticmethod\n    def get_params(img, scale, ratio):\n        \"\"\"Get parameters for ``crop`` for a random sized crop.\n\n        Args:\n            img (PIL Image): Image to be cropped.\n            scale (tuple): range of size of the origin size cropped\n            ratio (tuple): range of aspect ratio of the origin aspect ratio cropped\n\n        Returns:","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/data/transforms.py#L175-L211","documentation":"timm's RandomResizedCrop (and INTERCEPT mode variants) warn when scale=(min,max) or ratio=(min,max) is passed with min > max. Unlike naflex's _validate_range, here the values are NOT swapped — the range is used as-is, so sampling can behave unexpectedly.","triggerScenarios":"Creating RandomResizedCrop(224, scale=(0.9, 0.5)) or ratio=(4/3, 3/4); porting configs written as (max, min).","commonSituations":"Copy-pasted torchvision examples with reversed ratio; hand-tuned augmentation configs. Because no swap happens, downstream torch.empty(...).uniform_(lo, hi) with lo>hi raises or yields empty samples — fix the order.","solutions":["Rewrite ranges as (min, max)","Audit any augmentation config where ranges were authored as (max, min)"],"exampleFix":"# before\ntfm = RandomResizedCrop(224, scale=(1.0, 0.08), ratio=(4./3., 3./4.))\n# after\ntfm = RandomResizedCrop(224, scale=(0.08, 1.0), ratio=(3./4., 4./3.))","handlingStrategy":"validation","validationCode":"assert scale[0] <= scale[1] and ratio[0] <= ratio[1], 'ranges must be (min, max)'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Note: unlike naflex, this class does NOT auto-swap; reversed ranges break sampling","Standardize configs to (min, max) ordering"],"tags":["transforms","range-validation","augmentation","timm"],"backgroundTag":"reversed-min-max-range","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}