class_docstr: Object detector based on https://github.com/open-mmlab/mmdetection.
class_docstr_tok: ["Object","detector","based","on","https",":","\/\/github.com\/open-mmlab\/mmdetection","."]
code: def predict(self, tasks, **kwargs):
      assert len(tasks) == 1
      task = tasks[0]
      image_url = self._get_image_url(task)
      image_path = self.get_local_path(image_url)
      model_results = inference_detector(
          self.model, image_path
      ).pred_instances
      results = []
      all_scores = []
      img_width, img_height = get_image_size(image_path)
      print(f">>> model_results: {model_results}")
      print(f">>> label_map {self.label_map}")
      print(f">>> self.model.dataset_meta: {self.model.dataset_meta}")
      classes = self.model.dataset_meta.get("classes")
      print(f"Classes >>> {classes}")
      for item in model_results:
          print(f"item >>>>> {item}")
          bboxes, label, scores = (
              item["bboxes"],
              item["labels"],
              item["scores"],
          )
          score = float(scores[-1])
          if score < self.score_thresh:
              continue
          print(f"bboxes >>>>> {bboxes}")
          print(f"label >>>>> {label}")
          output_label = classes[
              list(self.label_map.get(label, label))[0]
          ]
          print(f">>> output_label: {output_label}")
          if output_label not in self.labels_in_config:
              print(
                  output_label + " label not found in project config."
              )
              continue
  
          for bbox in bboxes:
              bbox = list(bbox)
              if not bbox:
                  continue
  
              x, y, xmax, ymax = bbox[:4]
              results.append(
                  {
                      "from_name": self.from_name,
                      "to_name": self.to_name,
                      "type": "rectanglelabels",
                      "value": {
                          "rectanglelabels": [output_label],
                          "x": float(x) / img_width * 100,
                          "y": float(y) / img_height * 100,
                          "width": (float(xmax) - float(x))
                          / img_width
                          * 100,
                          "height": (float(ymax) - float(y))
                          / img_height
                          * 100,
                      },
                      "score": score,
                  }
              )
              all_scores.append(score)
      avg_score = sum(all_scores) / max(len(all_scores), 1)
      print(f">>> RESULTS: {results}")
      return [{"result": results, "score": avg_score}]
  
file_path: mmdetection/projects/LabelStudio/backend_template/mmdetection.py
imports: import io
  import json
  import logging
  import os
  from urllib.parse import urlparse
  import boto3
  from botocore.exceptions import ClientError
  from label_studio_ml.model import LabelStudioMLBase
  from label_studio_ml.utils import DATA_UNDEFINED_NAME, get_image_size, get_single_tag_keys
  from label_studio_tools.core.utils.io import get_data_dir
  from mmdet.apis import inference_detector, init_detector
label_desc: Use image node_id 3 for calling the MMDetection obj's underlying member method code with example usage: obj.predict(tasks) and returns: list