def METHOD_NAME(results, cocoGt, output):
    os.makedirs(output, exist_ok=True)
    new_results = collections.defaultdict(list)
    for result in results:
        new_results[result['image_id']].append(result)
    print("Unique images = {}".format(len(new_results)))
    results = new_results
    for k, result in results.items():
        draw = None
        image = None
        for v in result:
            box = v['bbox']
            score = v['score']
            predicted_class = v["category_id"]
            try:
                predicted_class = cocoGt.loadCats(predicted_class)[0]["name"]
            except Exception as ex:
                print("category {} not found, image {}".format(predicted_class, v["image_loc"]))
            # predicted_class = self.class_names[c]
            # "image_loc": "/home/gs/data/coco300/val2017/000000397133.jpg",
            if not draw:
                image = Image.open(v['image_loc'])
                if image.mode != 'RGB':
                    image = image.convert('RGB')
                draw = ImageDraw.Draw(image)
            # font = ImageFont.truetype(font='FreeMono.ttf',
            #            size=np.floor(3e-2 * image.size[1] + 0.5).astype('int32'))
            try:
                left, top, w, h = box
                bottom = top + h
                right = left + w
                top = max(0, np.floor(top + 0.5).astype('int32'))
                left = max(0, np.floor(left + 0.5).astype('int32'))
                bottom = min(image.size[1], np.floor(bottom + 0.5).astype('int32'))
                right = min(image.size[0], np.floor(right + 0.5).astype('int32'))
                label = '{} {:.2f}'.format(predicted_class, score)
                # label_size = draw.textsize(label, font)
                label_size = draw.textsize(label)
                if top - label_size[1] >= 0:
                    text_origin = tuple(np.array([left, top - label_size[1]]))
                else:
                    text_origin = tuple(np.array([left, top + 1]))
                color = ImageColor.getrgb("red")
                thickness = 0
                draw.rectangle([left + thickness, top + thickness, right - thickness, bottom - thickness], outline=color)
                draw.text(text_origin, label, fill=color)  # , font=font)
            except Exception as ex:
                print("{} failed, ex {}".format(v['image_loc'], ex))
        image.save(os.path.join(output, os.path.basename(v['image_loc'])))
        del draw