code: def test_auto_slice_image(self):
      # read coco file
      coco_path = "tests/data/coco_utils/terrain1_coco.json"
      coco = Coco.from_coco_dict_or_path(coco_path)
  
      output_file_name = None
      output_dir = None
      image_path = "tests/data/coco_utils/" + coco.images[0].file_name
      slice_image_result = slice_image(
          image=image_path,
          coco_annotation_list=coco.images[0].annotations,
          output_file_name=output_file_name,
          output_dir=output_dir,
          min_area_ratio=0.1,
          out_ext=".png",
          verbose=False,
      )
  
      self.assertEqual(len(slice_image_result.images), 18)
      self.assertEqual(len(slice_image_result.coco_images), 18)
      self.assertEqual(
          slice_image_result.coco_images[0].annotations, []
      )
      self.assertEqual(
          slice_image_result.coco_images[15].annotations[1].area, 7296
      )
      self.assertEqual(
          slice_image_result.coco_images[15].annotations[1].bbox,
          [17, 356, 48, 152],
      )
  
      image_cv = read_image(image_path)
      slice_image_result = slice_image(
          image=image_cv,
          coco_annotation_list=coco.images[0].annotations,
          output_file_name=output_file_name,
          output_dir=output_dir,
          min_area_ratio=0.1,
          out_ext=".png",
          verbose=False,
      )
  
      self.assertEqual(len(slice_image_result.images), 18)
      self.assertEqual(len(slice_image_result.coco_images), 18)
      self.assertEqual(
          slice_image_result.coco_images[0].annotations, []
      )
      self.assertEqual(
          slice_image_result.coco_images[15].annotations[1].area, 7296
      )
      self.assertEqual(
          slice_image_result.coco_images[15].annotations[1].bbox,
          [17, 356, 48, 152],
      )
  
      image_pil = Image.open(image_path)
      slice_image_result = slice_image(
          image=image_pil,
          coco_annotation_list=coco.images[0].annotations,
          output_file_name=output_file_name,
          output_dir=output_dir,
          min_area_ratio=0.1,
          out_ext=".png",
          verbose=False,
      )
  
      self.assertEqual(len(slice_image_result.images), 18)
      self.assertEqual(len(slice_image_result.coco_images), 18)
      self.assertEqual(
          slice_image_result.coco_images[0].annotations, []
      )
      self.assertEqual(
          slice_image_result.coco_images[15].annotations[1].area, 7296
      )
      self.assertEqual(
          slice_image_result.coco_images[15].annotations[1].bbox,
          [17, 356, 48, 152],
      )
  
file_path: sahi/tests/test_autoslice.py
imports: import unittest
  import numpy
  from PIL import Image
  from sahi.slicing import slice_coco, slice_image
  from sahi.utils.coco import Coco
  from sahi.utils.cv import read_image
label_desc: Use image node_id 1 for calling the TestAutoSlicing obj's underlying member method code with example usage: obj.test_auto_slice_image() without return types