code: def test_get_area_filtered_coco(self):
      from sahi.utils.coco import Coco
  
      coco_path = "tests/data/coco_utils/visdrone2019-det-train-first50image.json"
      image_dir = "tests/data/coco_utils/"
      min_area = 50
      max_area = 10000
      coco = Coco.from_coco_dict_or_path(coco_path, image_dir=image_dir)
      area_filtered_coco = coco.get_area_filtered_coco(
          min=min_area, max=max_area
      )
      self.assertEqual(
          len(coco.json["images"]),
          50,
      )
      self.assertEqual(
          len(area_filtered_coco.json["images"]),
          17,
      )
      self.assertGreater(
          area_filtered_coco.stats["min_annotation_area"],
          min_area,
      )
      self.assertLess(
          area_filtered_coco.stats["max_annotation_area"],
          max_area,
      )
      self.assertEqual(
          area_filtered_coco.image_dir,
          image_dir,
      )
      self.assertEqual(
          area_filtered_coco.stats["num_images"],
          len(area_filtered_coco.images),
      )
      self.assertEqual(
          area_filtered_coco.stats["num_annotations"],
          len(area_filtered_coco.json["annotations"]),
      )
  
      intervals_per_category = {
          "human": {"min": 20, "max": 10000},
          "vehicle": {"min": 50, "max": 15000},
      }
      area_filtered_coco = coco.get_area_filtered_coco(
          intervals_per_category=intervals_per_category
      )
  
      self.assertEqual(
          len(coco.json["images"]),
          50,
      )
      self.assertEqual(
          len(area_filtered_coco.json["images"]),
          24,
      )
      self.assertGreater(
          area_filtered_coco.stats["min_annotation_area"],
          min(
              intervals_per_category["human"]["min"],
              intervals_per_category["vehicle"]["min"],
          ),
      )
      self.assertLess(
          area_filtered_coco.stats["max_annotation_area"],
          max(
              intervals_per_category["human"]["max"],
              intervals_per_category["vehicle"]["max"],
          ),
      )
      self.assertEqual(
          area_filtered_coco.image_dir,
          image_dir,
      )
      self.assertEqual(
          area_filtered_coco.stats["num_images"],
          len(area_filtered_coco.images),
      )
      self.assertEqual(
          area_filtered_coco.stats["num_annotations"],
          len(area_filtered_coco.json["annotations"]),
      )
  
      intervals_per_category = {
          "human": {"min": 20, "max": 10000},
          "vehicle": {"min": 50, "max": 15000},
      }
      area_filtered_coco = coco.get_area_filtered_coco(
          intervals_per_category=intervals_per_category
      )
  
      self.assertEqual(
          len(coco.json["images"]),
          50,
      )
      self.assertEqual(
          len(area_filtered_coco.json["images"]),
          24,
      )
      self.assertGreater(
          area_filtered_coco.stats["min_annotation_area"],
          min(
              intervals_per_category["human"]["min"],
              intervals_per_category["vehicle"]["min"],
          ),
      )
      self.assertLess(
          area_filtered_coco.stats["max_annotation_area"],
          max(
              intervals_per_category["human"]["max"],
              intervals_per_category["vehicle"]["max"],
          ),
      )
      self.assertEqual(
          area_filtered_coco.image_dir,
          image_dir,
      )
      self.assertEqual(
          area_filtered_coco.stats["num_images"],
          len(area_filtered_coco.images),
      )
      self.assertEqual(
          area_filtered_coco.stats["num_annotations"],
          len(area_filtered_coco.json["annotations"]),
      )
  
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 18 for calling the TestCocoUtils obj's underlying member method code with example usage: obj.test_get_area_filtered_coco() without return types