{"record":{"id":"0f47ef3d6377630d","repo":"tensorflow/models","slug":"maximum-change-in-aspect-ratio-must-be-between-0-a","errorCode":null,"errorMessage":"maximum change in aspect ratio must be between 0 and 0.5","messagePattern":"maximum change in aspect ratio must be between 0 and 0\\.5","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/yolo/ops/preprocessing_ops.py","lineNumber":384,"sourceCode":"      scaled dimension / original dimension.\n    cast([original_width, original_height, width, height, ptop, pleft, pbottom,\n      pright], tf.float32): a `Tensor` containing the information of the image\n        andthe applied preprocessing.\n  \"\"\"\n\n  def intersection(a, b):\n    \"\"\"Finds the intersection between 2 crops.\"\"\"\n    minx = tf.maximum(a[0], b[0])\n    miny = tf.maximum(a[1], b[1])\n    maxx = tf.minimum(a[2], b[2])\n    maxy = tf.minimum(a[3], b[3])\n    return tf.convert_to_tensor([minx, miny, maxx, maxy])\n\n  def cast(values, dtype):\n    return [tf.cast(value, dtype) for value in values]\n\n  if jitter > 0.5 or jitter < 0:\n    raise ValueError('maximum change in aspect ratio must be between 0 and 0.5')\n\n  with tf.name_scope('resize_and_jitter_image'):\n    # Cast all parameters to a usable float data type.\n    jitter = tf.cast(jitter, tf.float32)\n    original_dtype, original_dims = image.dtype, tf.shape(image)[:2]\n\n    # original width, original height, desigered width, desired height\n    original_width, original_height, width, height = cast(\n        [original_dims[1], original_dims[0], desired_size[1], desired_size[0]],\n        tf.float32)\n\n    # Compute the random delta width and height etc. and randomize the\n    # location of the corner points.\n    jitter_width = original_width * jitter\n    jitter_height = original_height * jitter\n    pleft = random_uniform_strong(\n        -jitter_width, jitter_width, jitter_width.dtype, seed=seed)\n    pright = random_uniform_strong(","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/yolo/ops/preprocessing_ops.py#L366-L402","documentation":"Parameter validation in resize_and_jitter_image: the aspect-ratio-change limit must lie in (0, 0.5] — the jitter logic stretches and crops within that bound, and values outside it produce invalid crop geometry (degenerate or negative regions in the intersection math). Fires when the preprocessing config passes 0, a negative number, or something above 0.5 for the maximum aspect-ratio distortion.","triggerScenarios":"Thrown at official/projects/yolo/ops/preprocessing_ops.py:384 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the max aspect-ratio change parameter to a value in (0, 0.5], e.g. 0.1 or 0.25","Check the preprocessing YAML/flags for a zero, negative, or missing value that defaults badly","Use the same bounds as the reference augmentation configs"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}