code: def draw_top_nms_proposals(
      pred_dict, image, min_score=0.8, draw_gt=False
  ):
      logger.debug(
          "Top NMS proposals (min_score = {})".format(min_score)
      )
      scores = pred_dict["rpn_prediction"]["scores"]
      proposals = pred_dict["rpn_prediction"]["proposals"]
      top_scores_mask = scores > min_score
      scores = scores[top_scores_mask]
      proposals = proposals[top_scores_mask]
  
      sorted_idx = scores.argsort()[::-1]
      scores = scores[sorted_idx]
      proposals = proposals[sorted_idx]
  
      image_pil, draw = get_image_draw(image)
  
      fill_alpha = 70
  
      for topn, (score, proposal) in enumerate(zip(scores, proposals)):
          bbox = list(proposal)
          if (bbox[2] - bbox[0] <= 0) or (bbox[3] - bbox[1] <= 0):
              logger.debug(
                  "Proposal has negative area: {}".format(bbox)
              )
              continue
  
          draw.rectangle(
              bbox,
              fill=(0, 255, 0, fill_alpha),
              outline=(0, 255, 0, 50),
          )
  
          if np.abs(score - 1.0) <= 0.01:
              font_txt = "1"
          else:
              font_txt = "{:.2f}".format(score)[1:]
  
          draw.text(
              tuple([bbox[0], bbox[1]]),
              text=font_txt,
              font=font,
              fill=(0, 255, 0, 150),
          )
  
          fill_alpha -= 5
  
      if draw_gt:
          gt_bboxes = pred_dict["gt_bboxes"]
          for gt_box in gt_bboxes:
              draw.rectangle(
                  list(gt_box[:4]),
                  fill=(0, 0, 255, 60),
                  outline=(0, 0, 255, 150),
              )
  
      return image_pil
  
imports: import io
  import numpy
  import os
  import logging
  import PIL.Image
  import PIL.ImageDraw
  import PIL.ImageFont
  import tensorflow
  from .bbox_overlap import bbox_overlap
  from .bbox_transform import decode
  from base64 import b64encode
  from sys import stdout
label_desc: Use image node_id 16 for calling a global function with example usage: draw_top_nms_proposals(pred_dict, image, min_score, draw_gt) and returns: image_pil