code: def postprocess_answer(answer, category):
      if category == "refer_desc" or category == "refer_reason":
          pattern = r"\[.*?\]"
          matches = re.findall(pattern, answer)
          for match in matches:
              answer = answer.replace(" " + match, "")
      elif category == "ground_conv":
          pattern = r"\[.*?\]"
          matches = re.findall(pattern, answer)
          for match in matches:
              coor_cur = match.replace("[", "")
              coor_cur = coor_cur.replace("]", "")
              coor_cur = coor_cur.split(",")
              coor_cur = [float(i.strip()) for i in coor_cur]
              try:
                  assert len(coor_cur) == 4
              except:
                  print("Found a exception when parsing coordinates")
                  answer = answer.replace(match, "")
              converted_box_coor = [
                  coor_cur[0] / VOCAB_IMAGE_W,
                  coor_cur[1] / VOCAB_IMAGE_H,
                  coor_cur[2] / VOCAB_IMAGE_W,
                  coor_cur[3] / VOCAB_IMAGE_H,
              ]
              answer = answer.replace(
                  match,
                  f"[{converted_box_coor[0]:.3f}, {converted_box_coor[1]:.3f}, {converted_box_coor[2]:.3f}, {converted_box_coor[3]:.3f}]",
              )
  
      return answer
  
file_path: ml-ferret/ferret/eval/eval_gpt_review_3newclass.py
imports: import argparse
  import json
  import os
  import openai
  import time
  import re
  import pdb
  from tqdm import tqdm
label_desc: Use image node_id 2 for calling a global function with example usage: postprocess_answer(answer, category) and returns: answer