code: def transform_annotation(
      img_w,
      img_h,
      max_lanes,
      n_offsets,
      offsets_ys,
      n_strips,
      strip_size,
      anno,
  ):
      old_lanes = anno["lanes"]
  
      # removing lanes with less than 2 points
      old_lanes = filter(lambda x: len(x) > 1, old_lanes)
      # sort lane points by Y (bottom to top of the image)
      old_lanes = [
          sorted(lane, key=lambda x: -x[1]) for lane in old_lanes
      ]
      # remove points with same Y (keep first occurrence)
      old_lanes = [filter_lane(lane) for lane in old_lanes]
      # normalize the annotation coordinates
      old_lanes = [
          [
              [x * img_w / float(img_w), y * img_h / float(img_h)]
              for x, y in lane
          ]
          for lane in old_lanes
      ]
      # create tranformed annotations
      lanes = (
          np.ones(
              (max_lanes, 2 + 1 + 1 + 2 + n_offsets), dtype=np.float32
          )
          * -1e5
      )  # 2 scores, 1 start_y, 1 start_x, 1 theta, 1 length, S+1 coordinates
      lanes_endpoints = np.ones((max_lanes, 2))
      # lanes are invalid by default
      lanes[:, 0] = 1
      lanes[:, 1] = 0
      for lane_idx, lane in enumerate(old_lanes):
          if lane_idx >= max_lanes:
              break
  
          try:
              xs_outside_image, xs_inside_image = sample_lane(
                  lane, offsets_ys, img_w
              )
          except AssertionError:
              continue
          if len(xs_inside_image) <= 1:
              continue
          all_xs = np.hstack((xs_outside_image, xs_inside_image))
          lanes[lane_idx, 0] = 0
          lanes[lane_idx, 1] = 1
          lanes[lane_idx, 2] = len(xs_outside_image) / n_strips
          lanes[lane_idx, 3] = xs_inside_image[0]
  
          thetas = []
          for i in range(1, len(xs_inside_image)):
              theta = (
                  math.atan(
                      i
                      * strip_size
                      / (xs_inside_image[i] - xs_inside_image[0] + 1e-5)
                  )
                  / math.pi
              )
              theta = theta if theta > 0 else 1 - abs(theta)
              thetas.append(theta)
  
          theta_far = sum(thetas) / len(thetas)
  
          # lanes[lane_idx,
          #       4] = (theta_closest + theta_far) / 2  # averaged angle
          lanes[lane_idx, 4] = theta_far
          lanes[lane_idx, 5] = len(xs_inside_image)
          lanes[lane_idx, 6 : 6 + len(all_xs)] = all_xs
          lanes_endpoints[lane_idx, 0] = (len(all_xs) - 1) / n_strips
          lanes_endpoints[lane_idx, 1] = xs_inside_image[-1]
  
      new_anno = {
          "label": lanes,
          "old_anno": anno,
          "lane_endpoints": lanes_endpoints,
      }
      return new_anno
  
file_path: PaddleDetection/ppdet/data/culane_utils.py
imports: import math
  import numpy
  from imgaug.augmentables.lines import LineString
  from scipy.interpolate import InterpolatedUnivariateSpline
label_desc: Use image node_id 5 for calling a global function with example usage: transform_annotation(img_w, img_h, max_lanes, n_offsets, offsets_ys, n_strips, strip_size, anno) and returns: new_anno