code: def predict_fiftyone(
      model_type: str = "mmdet",
      model_path: str = None,
      model_config_path: str = None,
      model_confidence_threshold: float = 0.25,
      model_device: str = None,
      model_category_mapping: dict = None,
      model_category_remapping: dict = None,
      dataset_json_path: str = None,
      image_dir: str = None,
      no_standard_prediction: bool = False,
      no_sliced_prediction: bool = False,
      image_size: int = None,
      slice_height: int = 256,
      slice_width: int = 256,
      overlap_height_ratio: float = 0.2,
      overlap_width_ratio: float = 0.2,
      postprocess_type: str = "GREEDYNMM",
      postprocess_match_metric: str = "IOS",
      postprocess_match_threshold: float = 0.5,
      postprocess_class_agnostic: bool = False,
      verbose: int = 1,
  ):
      """
      Performs prediction for all present images in given folder.
  
      Args:
          model_type: str
              mmdet for 'MmdetDetectionModel', 'yolov5' for 'Yolov5DetectionModel'.
          model_path: str
              Path for the model weight
          model_config_path: str
              Path for the detection model config file
          model_confidence_threshold: float
              All predictions with score < model_confidence_threshold will be discarded.
          model_device: str
              Torch device, "cpu" or "cuda"
          model_category_mapping: dict
              Mapping from category id (str) to category name (str) e.g. {"1": "pedestrian"}
          model_category_remapping: dict: str to int
              Remap category ids after performing inference
          dataset_json_path: str
              If coco file path is provided, detection results will be exported in coco json format.
          image_dir: str
              Folder directory that contains images or path of the image to be predicted.
          no_standard_prediction: bool
              Dont perform standard prediction. Default: False.
          no_sliced_prediction: bool
              Dont perform sliced prediction. Default: False.
          image_size: int
              Input image size for each inference (image is scaled by preserving asp. rat.).
          slice_height: int
              Height of each slice.  Defaults to ``256``.
          slice_width: int
              Width of each slice.  Defaults to ``256``.
          overlap_height_ratio: float
              Fractional overlap in height of each window (e.g. an overlap of 0.2 for a window
              of size 256 yields an overlap of 51 pixels).
              Default to ``0.2``.
          overlap_width_ratio: float
              Fractional overlap in width of each window (e.g. an overlap of 0.2 for a window
              of size 256 yields an overlap of 51 pixels).
              Default to ``0.2``.
          postprocess_type: str
              Type of the postprocess to be used after sliced inference while merging/eliminating predictions.
              Options are 'NMM', 'GRREDYNMM' or 'NMS'. Default is 'GRREDYNMM'.
          postprocess_match_metric: str
              Metric to be used during object prediction matching after sliced prediction.
              'IOU' for intersection over union, 'IOS' for intersection over smaller area.
          postprocess_match_metric: str
              Metric to be used during object prediction matching after sliced prediction.
              'IOU' for intersection over union, 'IOS' for intersection over smaller area.
          postprocess_match_threshold: float
              Sliced predictions having higher iou than postprocess_match_threshold will be
              postprocessed after sliced prediction.
          postprocess_class_agnostic: bool
              If True, postprocess will ignore category ids.
          verbose: int
              0: no print
              1: print slice/prediction durations, number of slices, model loading/file exporting durations
      """
      check_requirements(["fiftyone"])
  
      from sahi.utils.fiftyone import (
          create_fiftyone_dataset_from_coco_file,
          fo,
      )
  
      # assert prediction type
      if no_standard_prediction and no_sliced_prediction:
          raise ValueError(
              "'no_standard_pred' and 'no_sliced_prediction' cannot be True at the same time."
          )
      # for profiling
      durations_in_seconds = dict()
  
      dataset = create_fiftyone_dataset_from_coco_file(
          image_dir, dataset_json_path
      )
  
      # init model instance
      time_start = time.time()
      detection_model = AutoDetectionModel.from_pretrained(
          model_type=model_type,
          model_path=model_path,
          config_path=model_config_path,
          confidence_threshold=model_confidence_threshold,
          device=model_device,
          category_mapping=model_category_mapping,
          category_remapping=model_category_remapping,
          load_at_init=False,
          image_size=image_size,
      )
      detection_model.load_model()
      time_end = time.time() - time_start
      durations_in_seconds["model_load"] = time_end
  
      # iterate over source images
      durations_in_seconds["prediction"] = 0
      durations_in_seconds["slice"] = 0
      # Add predictions to samples
      with fo.ProgressBar() as pb:
          for sample in pb(dataset):
              # perform prediction
              if not no_sliced_prediction:
                  # get sliced prediction
                  prediction_result = get_sliced_prediction(
                      image=sample.filepath,
                      detection_model=detection_model,
                      slice_height=slice_height,
                      slice_width=slice_width,
                      overlap_height_ratio=overlap_height_ratio,
                      overlap_width_ratio=overlap_width_ratio,
                      perform_standard_pred=not no_standard_prediction,
                      postprocess_type=postprocess_type,
                      postprocess_match_threshold=postprocess_match_threshold,
                      postprocess_match_metric=postprocess_match_metric,
                      postprocess_class_agnostic=postprocess_class_agnostic,
                      verbose=verbose,
                  )
                  durations_in_seconds[
                      "slice"
                  ] += prediction_result.durations_in_seconds["slice"]
              else:
                  # get standard prediction
                  prediction_result = get_prediction(
                      image=sample.filepath,
                      detection_model=detection_model,
                      shift_amount=[0, 0],
                      full_shape=None,
                      postprocess=None,
                      verbose=0,
                  )
                  durations_in_seconds[
                      "prediction"
                  ] += prediction_result.durations_in_seconds[
                      "prediction"
                  ]
  
              # Save predictions to dataset
              sample[model_type] = fo.Detections(
                  detections=prediction_result.to_fiftyone_detections()
              )
              sample.save()
  
      # print prediction duration
      if verbose == 1:
          print(
              "Model loaded in",
              durations_in_seconds["model_load"],
              "seconds.",
          )
          print(
              "Slicing performed in",
              durations_in_seconds["slice"],
              "seconds.",
          )
          print(
              "Prediction performed in",
              durations_in_seconds["prediction"],
              "seconds.",
          )
  
      # visualize results
      session = fo.launch_app()
      session.dataset = dataset
      # Evaluate the predictions
      results = dataset.evaluate_detections(
          model_type,
          gt_field="ground_truth",
          eval_key="eval",
          iou=postprocess_match_threshold,
          compute_mAP=True,
      )
      # Get the 10 most common classes in the dataset
      counts = dataset.count_values("ground_truth.detections.label")
      classes_top10 = sorted(counts, key=counts.get, reverse=True)[:10]
      # Print a classification report for the top-10 classes
      results.print_report(classes=classes_top10)
      # Load the view on which we ran the `eval` evaluation
      eval_view = dataset.load_evaluation_view("eval")
      # Show samples with most false positives
      session.view = eval_view.sort_by("eval_fp", reverse=True)
      while 1:
          time.sleep(3)
  
imports: import logging
  import os
  import time
  from typing import List, Optional
  from sahi.utils.import_utils import is_available
  from functools import cmp_to_key
  import numpy
  from tqdm import tqdm
  from sahi.auto_model import AutoDetectionModel
  from sahi.models.base import DetectionModel
  from sahi.postprocess.combine import GreedyNMMPostprocess, LSNMSPostprocess, NMMPostprocess, NMSPostprocess, PostprocessPredictions
  from sahi.prediction import ObjectPrediction, PredictionResult
  from sahi.slicing import slice_image
  from sahi.utils.coco import Coco, CocoImage
  from sahi.utils.cv import IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, crop_object_predictions, cv2, get_video_reader, read_image_as_pil, visualize_object_predictions
  from sahi.utils.file import Path, increment_path, list_files, save_json, save_pickle
  from sahi.utils.import_utils import check_requirements
label_desc: Use image node_id 6 for calling a global function with example usage: predict_fiftyone(model_type, model_path, model_config_path, model_confidence_threshold, model_device, model_category_mapping, model_category_remapping, dataset_json_path, image_dir, no_standard_prediction, no_sliced_prediction, image_size, slice_height, slice_width, overlap_height_ratio, overlap_width_ratio, postprocess_type, postprocess_match_metric, postprocess_match_threshold, postprocess_class_agnostic, verbose) without return types