code: def test_get_upsampled_coco(self):
      from sahi.utils.coco import Coco
      from sahi.utils.file import load_json
  
      coco_path = "tests/data/coco_utils/visdrone2019-det-train-first50image.json"
      image_dir = "tests/data/coco_utils/"
      coco = Coco.from_coco_dict_or_path(coco_path, image_dir=image_dir)
      UPSAMPLE_RATIO = 5
      upsampled_coco = coco.get_upsampled_coco(
          upsample_ratio=UPSAMPLE_RATIO
      )
      self.assertEqual(
          len(coco.json["images"]),
          50,
      )
      self.assertEqual(
          len(upsampled_coco.json["images"]),
          250,
      )
      self.assertEqual(
          len(coco.images[5].annotations),
          len(upsampled_coco.images[5 + len(coco.images)].annotations),
      )
      self.assertEqual(
          coco.image_dir,
          image_dir,
      )
      self.assertEqual(
          upsampled_coco.image_dir,
          image_dir,
      )
      self.assertEqual(
          upsampled_coco.stats["num_images_per_category"]["vehicle"],
          coco.stats["num_images_per_category"]["vehicle"]
          * UPSAMPLE_RATIO,
      )
      self.assertEqual(
          upsampled_coco.stats["num_images"], len(upsampled_coco.images)
      )
      self.assertEqual(
          upsampled_coco.stats["num_annotations"],
          len(upsampled_coco.json["annotations"]),
      )
  
      vehicle_upsampled_coco = coco.get_upsampled_coco(
          upsample_ratio=UPSAMPLE_RATIO, category_id=1
      )
      self.assertEqual(
          vehicle_upsampled_coco.stats["num_images_per_category"][
              "vehicle"
          ],
          coco.stats["num_images_per_category"]["vehicle"]
          * UPSAMPLE_RATIO,
      )
      self.assertNotEqual(
          vehicle_upsampled_coco.stats["num_images_per_category"][
              "human"
          ],
          coco.stats["num_images_per_category"]["human"]
          * UPSAMPLE_RATIO,
      )
  
      negative_upsampled_coco = coco.get_upsampled_coco(
          upsample_ratio=UPSAMPLE_RATIO, category_id=-1
      )
      self.assertEqual(
          negative_upsampled_coco.stats["num_images_per_category"][
              "vehicle"
          ],
          coco.stats["num_images_per_category"]["vehicle"],
      )
      self.assertEqual(
          negative_upsampled_coco.stats["num_negative_images"],
          coco.stats["num_negative_images"] * UPSAMPLE_RATIO,
      )
  
imports: import os
  import shutil
  import unittest
  from sahi.utils.coco import merge, update_categories
  from sahi.utils.file import load_json
label_desc: Use image node_id 17 for calling the TestCocoUtils obj's underlying member method code with example usage: obj.test_get_upsampled_coco() without return types