class_docstr: Zero shot object detection pipeline using `OwlViTForObjectDetection`. This pipeline predicts bounding boxes of
  objects when you provide an image and a set of `candidate_labels`.
  
  This object detection pipeline can currently be loaded from [`pipeline`] using the following task identifier:
  `"zero-shot-object-detection"`.
  
  See the list of available models on
  [huggingface.co/models](https://huggingface.co/models?filter=zero-shot-object-detection).
class_docstr_tok: ["Zero","shot","object","detection","pipeline","using","`","OwlViTForObjectDetection","`",".","This","pipeline","predicts","bounding","boxes","of","objects","when","you","provide","an","image","and","a","set","of","`","candidate_labels","`",".","This","object","detection","pipeline","can","currently","be","loaded","from","[","`","pipeline","`","]","using","the","following","task","identifier",":","`","``","zero-shot-object-detection","''","`",".","See","the","list","of","available","models","on","[","huggingface.co\/models","]","(","https",":","\/\/huggingface.co\/models","?","filter=zero-shot-object-detection",")","."]
docstr: Detect objects (bounding boxes & classes) in the image(s) passed as inputs.
  
  Args:
      images (`str`, `List[str]`, `PIL.Image` or `List[PIL.Image]`):
          The pipeline handles three types of images:
  
          - A string containing an http url pointing to an image
          - A string containing a local path to an image
          - An image loaded in PIL directly
  
      text_queries (`str` or `List[str]` or `List[List[str]]`): Text queries to query the target image with.
      If given multiple images, `text_queries` should be provided as a list of lists, where each nested list
      contains the text queries for the corresponding image.
  
      threshold (`float`, *optional*, defaults to 0.1):
          The probability necessary to make a prediction.
  
      top_k (`int`, *optional*, defaults to None):
          The number of top predictions that will be returned by the pipeline. If the provided number is `None`
          or higher than the number of predictions available, it will default to the number of predictions.
  
  
  Return:
      A list of lists containing prediction results, one list per input image. Each list contains dictionaries
      with the following keys:
  
      - **label** (`str`) -- Text query corresponding to the found object.
      - **score** (`float`) -- Score corresponding to the object (between 0 and 1).
      - **box** (`Dict[str,int]`) -- Bounding box of the detected object in image's original size. It is a
        dictionary with `x_min`, `x_max`, `y_min`, `y_max` keys.
docstr_tok: ["Detect","objects","(","bounding","boxes","&","classes",")","in","the","image","(","s",")","passed","as","inputs",".","Args",":","images","(","`","str","`",",","`","List","[","str","]","`",",","`","PIL.Image","`","or","`","List","[","PIL.Image","]","`",")",":","The","pipeline","handles","three","types","of","images",":","-","A","string","containing","an","http","url","pointing","to","an","image","-","A","string","containing","a","local","path","to","an","image","-","An","image","loaded","in","PIL","directly","text_queries","(","`","str","`","or","`","List","[","str","]","`","or","`","List","[","List","[","str","]","]","`",")",":","Text","queries","to","query","the","target","image","with",".","If","given","multiple","images",",","`","text_queries","`","should","be","provided","as","a","list","of","lists",",","where","each","nested","list","contains","the","text","queries","for","the","corresponding","image",".","threshold","(","`","float","`",",","*","optional","*",",","defaults","to","0.1",")",":","The","probability","necessary","to","make","a","prediction",".","top_k","(","`","int","`",",","*","optional","*",",","defaults","to","None",")",":","The","number","of","top","predictions","that","will","be","returned","by","the","pipeline",".","If","the","provided","number","is","`","None","`","or","higher","than","the","number","of","predictions","available",",","it","will","default","to","the","number","of","predictions",".","Return",":","A","list","of","lists","containing","prediction","results",",","one","list","per","input","image",".","Each","list","contains","dictionaries","with","the","following","keys",":","-","*","*","label","*","*","(","`","str","`",")","--","Text","query","corresponding","to","the","found","object",".","-","*","*","score","*","*","(","`","float","`",")","--","Score","corresponding","to","the","object","(","between","0","and","1",")",".","-","*","*","box","*","*","(","`","Dict","[","str",",","int","]","`",")","--","Bounding","box","of","the","detected","object","in","image","'s","original","size",".","It","is","a","dictionary","with","`","x_min","`",",","`","x_max","`",",","`","y_min","`",",","`","y_max","`","keys","."]
code: def __call__(
      self,
      images: Union[str, List[str], "Image.Image", List["Image.Image"]],
      text_queries: Union[str, List[str], List[List[str]]] = None,
      **kwargs,
  ):
      """
      Detect objects (bounding boxes & classes) in the image(s) passed as inputs.
  
      Args:
          images (`str`, `List[str]`, `PIL.Image` or `List[PIL.Image]`):
              The pipeline handles three types of images:
  
              - A string containing an http url pointing to an image
              - A string containing a local path to an image
              - An image loaded in PIL directly
  
          text_queries (`str` or `List[str]` or `List[List[str]]`): Text queries to query the target image with.
          If given multiple images, `text_queries` should be provided as a list of lists, where each nested list
          contains the text queries for the corresponding image.
  
          threshold (`float`, *optional*, defaults to 0.1):
              The probability necessary to make a prediction.
  
          top_k (`int`, *optional*, defaults to None):
              The number of top predictions that will be returned by the pipeline. If the provided number is `None`
              or higher than the number of predictions available, it will default to the number of predictions.
  
  
      Return:
          A list of lists containing prediction results, one list per input image. Each list contains dictionaries
          with the following keys:
  
          - **label** (`str`) -- Text query corresponding to the found object.
          - **score** (`float`) -- Score corresponding to the object (between 0 and 1).
          - **box** (`Dict[str,int]`) -- Bounding box of the detected object in image's original size. It is a
            dictionary with `x_min`, `x_max`, `y_min`, `y_max` keys.
      """
      if isinstance(text_queries, str) or (
          isinstance(text_queries, List)
          and not isinstance(text_queries[0], List)
      ):
          if isinstance(images, (str, Image.Image)):
              inputs = {"images": images, "text_queries": text_queries}
          elif isinstance(images, List):
              assert (
                  len(images) == 1
              ), "Input text_queries and images must have correspondance"
              inputs = {
                  "images": images[0],
                  "text_queries": text_queries,
              }
          else:
              raise TypeError(
                  f"Innapropriate type of images: {type(images)}"
              )
  
      elif isinstance(text_queries, str) or (
          isinstance(text_queries, List)
          and isinstance(text_queries[0], List)
      ):
          if isinstance(images, (Image.Image, str)):
              images = [images]
          assert len(images) == len(
              text_queries
          ), "Input text_queries and images must have correspondance"
          inputs = {"images": images, "text_queries": text_queries}
      else:
          """
          Supports the following format
          - {"images": images, "text_queries": text_queries}
          """
          inputs = images
      results = super().__call__(inputs, **kwargs)
      return results
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/src/transformers/pipelines/zero_shot_object_detection.py
imports: from typing import Dict, List, Union
  import numpy
  from ..tokenization_utils_base import BatchEncoding
  from ..utils import add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends
  from .base import PIPELINE_INIT_ARGS, Pipeline
label_desc: Use image node_id 2 for calling the ZeroShotObjectDetectionPipeline obj's underlying member method code with example usage: obj.__call__(images, text_queries) and returns: results