Returns: Results: A new Results object with attributes modified by the applied function. **kwargs: Arbitrary keyword arguments to pass to the function. *args: Variable length argument list to pass to the function. Args: fn (str): The name of the function to apply. This function is internally called by methods like. probs = probs def _apply ( self, fn, * args, ** kwargs ): """ Applies a function to all non-empty attributes and returns a new Results object with modified attributes. orig_shape ) if probs is not None : self. orig_shape ) if masks is not None : self. _keys : v = getattr ( self, k ) if v is not None : return len ( v ) def update ( self, boxes = None, masks = None, probs = None ): """Update the boxes, masks, and probs attributes of the Results object.""" if boxes is not None : self. _apply ( '_getitem_', idx ) def _len_ ( self ): """Return the number of detections in the Results object.""" for k in self. _keys = 'boxes', 'masks', 'probs', 'keypoints' def _getitem_ ( self, idx ): """Return a Results object for the specified index.""" return self. orig_shape ) if keypoints is not None else None self. keypoints = Keypoints ( keypoints, self. probs = Probs ( probs ) if probs is not None else None self. orig_shape ) if masks is not None else None # native size or imgsz masks self. orig_shape ) if boxes is not None else None # native size boxes self. """ def _init_ ( self, orig_img, path, names, boxes = None, masks = None, probs = None, keypoints = None ) -> None : """Initialize the Results class.""" self. _keys (tuple): A tuple of attribute names for non-empty attributes. names (dict): A dictionary of class names. speed (dict): A dictionary of preprocess, inference, and postprocess speeds in milliseconds per image. keypoints (Keypoints, optional): A Keypoints object containing detected keypoints for each object. probs (Probs, optional): A Probs object containing probabilities of each class for classification task. masks (Masks, optional): A Masks object containing the detection masks. boxes (Boxes, optional): A Boxes object containing the detection bounding boxes. orig_shape (tuple): The original image shape in (height, width) format. Attributes: orig_img (numpy.ndarray): The original image as a numpy array. keypoints (List], optional): A list of detected keypoints for each object. probs (torch.tensor, optional): A 1D tensor of probabilities of each class for classification task. masks (torch.tensor, optional): A 3D tensor of detection masks, where each mask is a binary image. boxes (torch.tensor, optional): A 2D tensor of bounding box coordinates for each detection. Args: orig_img (numpy.ndarray): The original image as a numpy array. orig_shape )Ĭlass Results ( SimpleClass ): """ A class for storing and manipulating inference results. data ) def _getitem_ ( self, idx ): """Return a BaseTensor with the specified index of the data tensor.""" return self. orig_shape ) def _len_ ( self ): # override len(results) """Return the length of the data tensor.""" return len ( self. orig_shape ) def to ( self, * args, ** kwargs ): """Return a copy of the tensor with the specified device and dtype.""" return self. orig_shape ) def cuda ( self ): """Return a copy of the tensor on GPU memory.""" return self. orig_shape ) def numpy ( self ): """Return a copy of the tensor as a numpy array.""" return self if isinstance ( self. shape def cpu ( self ): """Return a copy of the tensor on CPU memory.""" return self if isinstance ( self. orig_shape = orig_shape def shape ( self ): """Return the shape of the data tensor.""" return self. orig_shape (tuple): Original shape of image. Args: data (torch.Tensor | np.ndarray): Predictions, such as bboxes, masks and keypoints. Class BaseTensor ( SimpleClass ): """Base tensor class with additional methods for easy manipulation and device handling.""" def _init_ ( self, data, orig_shape ) -> None : """ Initialize BaseTensor with data and original shape.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |