id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
188,634 | from mmdeploy.core import SYMBOLIC_REWRITER
The provided code snippet includes necessary dependencies for implementing the `deform_conv__default` function. Write a Python function `def deform_conv__default(g, input, offset, weight, ... | Rewrite symbolic function for default backend. |
188,635 | from mmdeploy.core import SYMBOLIC_REWRITER
The provided code snippet includes necessary dependencies for implementing the `deform_conv_openvino` function. Write a Python function `def deform_conv_openvino(g, input, offset, weight, ... | Rewrite symbolic function for OpenVINO backend. |
188,636 | from mmdeploy.core import SYMBOLIC_REWRITER
The provided code snippet includes necessary dependencies for implementing the `ms_deform_attn_default` function. Write a Python function `def ms_deform_attn_default( g, value, value_spatial_shapes, value_level_start_index, sampling_locations, attenti... | Rewrite msda symbolic function for all backend. |
188,637 | import torch
from mmdeploy.core import FUNCTION_REWRITER, SYMBOLIC_REWRITER
from mmdeploy.utils import IR
from mmdeploy.backend.torchscript import get_ops_path, ops_available
assert ops_available(), 'torchscript custom ops is required.'
torch.ops.load_library(get_ops_path())
from torch.nn.modules.utils ... | rewriter for the custom torchscript mdcn op. |
188,638 | import torch
from mmdeploy.core import FUNCTION_REWRITER, SYMBOLIC_REWRITER
from mmdeploy.utils import IR
from mmdeploy.backend.torchscript import get_ops_path, ops_available
from torch.nn.modules.utils import _pair
The provided code snippet includes necessary dependencies for implementing the `modulated_defor... | Rewrite mdcn symbolic function for all backend. |
188,639 | import torch.nn.functional as F
from mmdeploy.core import FUNCTION_REWRITER
from mmcv.ops.point_sample import denormalize
add_dim = False
output = F.grid_sample(
input, denormalize(points), align_corners=align_corners, **kwargs)
if add_dim:
output = output.squeeze(3)
return output
T... | A wrapper around :func:`grid_sample` to support 3D point_coords tensors Unlike :func:`torch.nn.functional.grid_sample` it assumes point_coords to lie inside ``[0, 1] x [0, 1]`` square. Args: input (torch.Tensor): Feature map, shape (N, C, H, W). points (torch.Tensor): Image based absolute point coordinates (normalized)... |
188,640 | import torch.nn.functional as F
from mmdeploy.core import FUNCTION_REWRITER
from mmcv.ops.point_sample import denormalize
The provided code snippet includes necessary dependencies for implementing the `simple_roialign__forward` function. Write a Python function `def simple_roialign__forward(self, features, rois)` ... | Rewrite `forward` of SimpleRoIAlign. Args: features (torch.Tensor): Feature map, shape (N, C, H, W). rois (torch.Tensor): Returns: torch.Tensor: RoI features. |
188,641 | import torch
from mmdeploy.codebase.mmdet.deploy import clip_bboxes
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `distance2bbox__default` function. Write a Python function `def distance2bbox__default(points, distance, max_shape=None)` to sol... | Rewrite `mmdet.core.bbox.transforms.distance2bbox` Decode distance prediction to bounding box. Args: ctx (ContextCaller): The context with additional information. points (Tensor): Shape (B, N, 2) or (N, 2). distance (Tensor): Distance from the given point to 4 boundaries (left, top, right, bottom). Shape (B, N, 4) or (... |
188,642 | import copy
import math
from functools import partial
from typing import Any, List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
import torch.nn.functional as F
from mmengine import Config
from mmengine.model.base_model.data_preprocessor import BaseDataPreprocessor
from mmengine.registry import Regi... | Build object detection model for different backends. Args: model_files (Sequence[str]): Input model file(s). model_cfg (str | Config): Input model config file or Config object. deploy_cfg (str | Config): Input deployment config file or Config object. device (str): Device to input model data_preprocessor (BaseDataPrepro... |
188,643 | from typing import Any, Optional, Sequence, Tuple, Union
import mmengine
import torch
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.core.rewriters.rewriter_utils import LibVersionChecker
from mmdeploy.utils import Backend, load_config
The provided code snippet includes necessary de... | Get mmdet post-processing parameters from config. Args: deploy_cfg (str | mmengine.Config): The path or content of config. Returns: dict: A dict of parameters for mmdet. |
188,644 | from typing import Any, Optional, Sequence, Tuple, Union
import mmengine
import torch
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.core.rewriters.rewriter_utils import LibVersionChecker
from mmdeploy.utils import Backend, load_config
The provided code snippet includes necessary de... | Clip bboxes for onnx. Since torch.clamp cannot have dynamic `min` and `max`, we scale the boxes by 1/max_shape and clamp in the range [0, 1] if necessary. Args: x1 (Tensor): The x1 for bounding boxes. y1 (Tensor): The y1 for bounding boxes. x2 (Tensor): The x2 for bounding boxes. y2 (Tensor): The y2 for bounding boxes.... |
188,645 | from typing import Any, Optional, Sequence, Tuple, Union
import mmengine
import torch
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.core.rewriters.rewriter_utils import LibVersionChecker
from mmdeploy.utils import Backend, load_config
The provided code snippet includes necessary de... | Clip bboxes for onnx. From TensorRT 8 we can do the operators on the tensors directly. Args: ctx (ContextCaller): The context with additional information. x1 (Tensor): The x1 for bounding boxes. y1 (Tensor): The y1 for bounding boxes. x2 (Tensor): The x2 for bounding boxes. y2 (Tensor): The y2 for bounding boxes. max_s... |
188,646 | from typing import Any, Optional, Sequence, Tuple, Union
import mmengine
import torch
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.core.rewriters.rewriter_utils import LibVersionChecker
from mmdeploy.utils import Backend, load_config
def __pad_with_value_if_necessary(x: Tensor,
... | Pad a tensor with a value along some dim if necessary. Args: x (Tensor): Input tensor. pad_dim (int): Along which dim to pad. pad_size (int): To which size to pad. pad_value (Any): Filled value for padding. Defaults to `None`. Returns: Tensor: Padded tensor. |
188,647 | from typing import Any, Optional, Sequence, Tuple, Union
import mmengine
import torch
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.core.rewriters.rewriter_utils import LibVersionChecker
from mmdeploy.utils import Backend, load_config
def pad_with_value(x: Tensor,
... | Pad a tensor with a value along some dim. Args: x (Tensor): Input tensor. pad_dim (int): Along which dim to pad. pad_size (int): To which size to pad. pad_value (Any): Filled value for padding. Defaults to `None`. Returns: Tensor: Padded tensor. |
188,648 | from typing import Any, Optional, Sequence, Tuple, Union
import mmengine
import torch
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.core.rewriters.rewriter_utils import LibVersionChecker
from mmdeploy.utils import Backend, load_config
class TRTGatherTopk(torch.autograd.Function):
... | TensorRT gather_topk. |
188,649 | from typing import Any, Optional, Sequence, Tuple, Union
import mmengine
import torch
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.core.rewriters.rewriter_utils import LibVersionChecker
from mmdeploy.utils import Backend, load_config
The provided code snippet includes necessary de... | Single batch gather_topk. |
188,650 | from typing import Any, Optional, Sequence, Tuple, Union
import mmengine
import torch
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.core.rewriters.rewriter_utils import LibVersionChecker
from mmdeploy.utils import Backend, load_config
def __gather_topk(*inputs: Sequence[torch.Tensor... | Gather topk of each tensor. Args: inputs (Sequence[torch.Tensor]): Tensors to be gathered. inds (torch.Tensor): Topk index. batch_size (int): batch_size. is_batched (bool): Inputs is batched or not. Returns: Tuple[torch.Tensor]: Gathered tensors. |
188,651 | from copy import deepcopy
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import numpy as np
import torch
from mmengine import Config
from mmengine.dataset import pseudo_collate
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Registry
from mmdeploy.codebase.base import ... | Process the model config. Args: model_cfg (Config): The model config. imgs (Sequence[str] | Sequence[np.ndarray]): Input image(s), accepted data type are List[str], List[np.ndarray]. input_shape (list[int]): A list of two integer in (width, height) format specifying input shape. Default: None. Returns: Config: the mode... |
188,652 | from copy import deepcopy
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import numpy as np
import torch
from mmengine import Config
from mmengine.dataset import pseudo_collate
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Registry
from mmdeploy.codebase.base import ... | Get metainfo of dataset. Args: model_cfg Config: Input model Config object. Returns: list[str]: A list of string specifying names of different class. |
188,653 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import get_common_config
The provided code snippet includes necessary dependencies for implementing the `focus__forward__default` function. Write a Python function `def focus__forward__default(self, x)` to solve the following problem:
Rewrite... | Rewrite forward function of Focus class. Replace slice with transpose. |
188,654 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import get_common_config
The provided code snippet includes necessary dependencies for implementing the `focus__forward__ncnn` function. Write a Python function `def focus__forward__ncnn(self, x)` to solve the following problem:
Rewrite forwa... | Rewrite forward function of Focus class for ncnn. Focus width and height information into channel space. ncnn does not support slice operator which step greater than 1, so we use another way to implement. Args: x (Tensor): The input tensor with shape (N, C, H, W). Returns: x (Tensor): The calculated tensor with shape (... |
188,655 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import get_common_config
The provided code snippet includes necessary dependencies for implementing the `windowmsa__forward__tensorrt` function. Write a Python function `def windowmsa__forward__tensorrt(self, x, mask=None)` to solve the follo... | Rewrite forward function of WindowMSA class for TensorRT. 1. replace Gather operation of qkv with split. 2. replace SoftMax operation with a workaround done by PyTorch. Args: x (tensor): input features with shape of (num_windows*B, N, C) mask (tensor | None, Optional): mask with shape of (num_windows, Wh*Ww, Wh*Ww), va... |
188,656 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import get_common_config
The provided code snippet includes necessary dependencies for implementing the `shift_window_msa__window_reverse__tensorrt` function. Write a Python function `def shift_window_msa__window_reverse__tensorrt(self, windo... | Rewrite window_reverse function of ShiftWindowMSA class for TensorRT. For TensorRT, seems radical shape transformations are not allowed. Replace them with soft ones. Args: windows: (num_windows*B, window_size, window_size, C) H (int): Height of image W (int): Width of image Returns: x: (B, H, W, C) |
188,657 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import get_common_config
The provided code snippet includes necessary dependencies for implementing the `shift_window_msa__window_partition__tensorrt` function. Write a Python function `def shift_window_msa__window_partition__tensorrt(self, x... | Rewrite window_partition function of ShiftWindowMSA class for TensorRT. For TensorRT, seems radical shape transformations are not allowed. Replace them with soft ones. Args: x: (B, H, W, C) Returns: windows: (num_windows*B, window_size, window_size, C) |
188,658 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import get_common_config
The provided code snippet includes necessary dependencies for implementing the `shift_window_msa__forward__default` function. Write a Python function `def shift_window_msa__forward__default(self, query, hw_shape)` to ... | Rewrite forward function of ShiftWindowMSA class. 1. replace dynamic padding with static padding and dynamic slice. 2. always do slice `x = x[:, :H, :W, :].contiguous()` for stability. |
188,659 | import torch
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `patch_merging__forward__tensorrt` function. Write a Python function `def patch_merging__forward__tensorrt(self, x, input_size)` to solve the following problem:
Rewrite forward functi... | Rewrite forward function of PatchMerging class for TensorRT. In original implementation, mmdet applies nn.unfold to accelerate the inference. However, the onnx graph of it can not be parsed correctly by TensorRT. In mmdeploy, it is replaced. Args: x (Tensor): Has shape (B, H*W, C_in). input_size (tuple[int]): The spati... |
188,660 | import torch
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `mask_matrix_nms__default` function. Write a Python function `def mask_matrix_nms__default(masks, labels, scores, ... | Matrix NMS for multi-class masks. Args: masks (Tensor): Has shape (num_instances, h, w) labels (Tensor): Labels of corresponding masks, has shape (num_instances,). scores (Tensor): Mask scores of corresponding masks, has shape (num_instances). filter_thr (float): Score threshold to filter the masks after matrix nms. De... |
188,661 | from typing import List, Optional
import torch
from mmengine.config import ConfigDict
from mmengine.structures import InstanceData
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.mmcv.ops import multiclass_nms
The ... | Rewrite `predict_by_feat` of `FoveaHead` for default backend. Rewrite this function to deploy model, transform network output for a batch into bbox predictions. Args: ctx (ContextCaller): The context with additional information. self (FoveaHead): The instance of the class FoveaHead. cls_scores (list[Tensor]): Box score... |
188,662 | from typing import List
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `centernet_head__predict_by_feat__default` function. Write a Python function `def centernet_head__predict_by_feat__default( self, c... | Rewrite `centernethead` of `CenterNetHead` for default backend. |
188,663 | from typing import Dict, List, Optional
import torch
from mmdet.models.utils import aligned_bilinear
from mmengine.config import ConfigDict
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.mmcv.ops.nms import multicl... | null |
188,664 | from typing import Dict, List, Optional
import torch
from mmdet.models.utils import aligned_bilinear
from mmengine.config import ConfigDict
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.mmcv.ops.nms import multicl... | null |
188,665 | from typing import Dict, List, Optional
import torch
from mmdet.models.utils import aligned_bilinear
from mmengine.config import ConfigDict
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.mmcv.ops.nms import multicl... | null |
188,666 | from typing import List
import torch
from torch import Tensor
from torch.nn import functional as F
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `detrhead__predict_by_feat__default` function. Write a Python function `def detrhead__predict_by_... | Rewrite `predict_by_feat` of `FoveaHead` for default backend. |
188,667 | from typing import List, Optional, Sequence
import torch
from mmengine.config import ConfigDict
from mmengine.structures import InstanceData
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import (gather_topk,
get_post_processing_params,
... | Rewrite of `points2bbox` in `RepPointsHead`. Use `self.moment_transfer` in `points2bbox` will cause error: RuntimeError: Input, output and indices must be on the current device |
188,668 | from typing import List, Optional, Sequence
import torch
from mmengine.config import ConfigDict
from mmengine.structures import InstanceData
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import (gather_topk,
get_post_processing_params,
... | Rewrite `predict_by_feat` of `RepPointsHead` for default backend. Rewrite this function to deploy model, transform network output for a batch into bbox predictions. Args: ctx (ContextCaller): The context with additional information. self (RepPointsHead): The instance of the class RepPointsHead. cls_scores (list[Tensor]... |
188,669 | from typing import Sequence
import numpy as np
import torch
from mmdet.utils import OptConfigType
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER, mark
from mmdeploy.mmcv.ops import multiclass_nms
from mmdeploy.utils import Backe... | Rewrite `predict_by_feat` of `YOLOV3Head` for default backend. Rewrite this function to deploy model, transform network output for a batch into bbox predictions. Args: ctx (ContextCaller): The context with additional information. pred_maps (Sequence[Tensor]): Raw predictions for a batch of images. cfg (ConfigDict, opti... |
188,670 | from typing import Sequence
import numpy as np
import torch
from mmdet.utils import OptConfigType
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER, mark
from mmdeploy.mmcv.ops import multiclass_nms
from mmdeploy.utils import Backe... | Rewrite `predict_by_feat` of YOLOV3Head for ncnn backend. 1. Shape node and batch inference is not supported by ncnn. This function transform dynamic shape to constant shape and remove batch inference. 2. Batch dimension is not supported by ncnn, but supported by pytorch. The negative value of axis in torch.cat is rewr... |
188,671 | from typing import List, Optional
import torch
from mmengine import ConfigDict
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import (gather_topk,
get_post_processing_params,
pad_with_value_if_necessary)
from mmdeploy.... | Rewrite `predict_by_feat` of `RPNHead` for default backend. Rewrite this function to deploy model, transform network output for a batch into bbox predictions. Args: ctx (ContextCaller): The context with additional information. cls_scores (list[Tensor]): Classification scores for all scale levels, each is a 4D-tensor, h... |
188,672 | from typing import List, Optional
import torch
from mmengine import ConfigDict
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import (gather_topk,
get_post_processing_params,
pad_with_value_if_necessary)
from mmdeploy.... | Rewrite `get_bboxes` of `RPNHead` for ncnn backend. Shape node and batch inference is not supported by ncnn. This function transform dynamic shape to constant shape and remove batch inference. Args: ctx (ContextCaller): The context with additional information. cls_scores (list[Tensor]): Box scores for each level in the... |
188,673 | from typing import Dict, List
import torch
import torch.nn.functional as F
from mmdet.models.layers.matrix_nms import mask_matrix_nms
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary d... | Rewrite `predict_by_feat` of `SOLOV2Head` for default backend. Args: mlvl_kernel_preds (list[Tensor]): Multi-level dynamic kernel prediction. The kernel is used to generate instance segmentation masks by dynamic convolution. Each element in the list has shape (batch_size, kernel_out_channels, num_grids, num_grids). mlv... |
188,674 | from typing import List, Optional
import torch
from mmengine.config import ConfigDict
from mmengine.structures import InstanceData
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER, mark
from mmdeploy.mmcv.ops import multiclass_nms... | Rewrite `predict_by_feat` of `YOLOXHead` for default backend. Rewrite this function to deploy model, transform network output for a batch into bbox predictions. Args: ctx: Context that contains original meta information. cls_scores (list[Tensor]): Classification scores for all scale levels, each is a 4D-tensor, has sha... |
188,675 | from typing import List, Optional
import torch
from mmengine.config import ConfigDict
from mmengine.structures import InstanceData
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER, mark
from mmdeploy.mmcv.ops import multiclass_nms... | Rewrite `predict_by_feat` of YOLOXHead for ncnn backend. 1. Decode the prior to a box format for ncnn DetectionOutput layer to do the post-processing. 2. Batch dimension is not supported by ncnn, but supported by pytorch. The negative value of axis in torch.cat is rewritten as corresponding positive value to avoid axis... |
188,676 | from typing import Dict, List
import torch
from mmdet.models.layers import mask_matrix_nms
from mmdet.utils import OptConfigType
from torch import Tensor
from torch.nn import functional as F
from mmdeploy.codebase.mmdet.deploy import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER
The provided c... | Rewrite `predict_by_feat` of `SOLOHead` for default backend. |
188,677 | from typing import List, Optional
import torch
from mmengine.config import ConfigDict
from mmengine.structures import InstanceData
from torch import Tensor
from mmdeploy.codebase.mmdet import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER, mark
from mmdeploy.mmcv.ops import multiclass_nms
from m... | Rewrite `predict_by_feat` of `RTMDet` for default backend. Rewrite this function to deploy model, transform network output for a batch into bbox predictions. Args: ctx: Context that contains original meta information. cls_scores (list[Tensor]): Classification scores for all scale levels, each is a 4D-tensor, has shape ... |
188,678 | from typing import List, Optional
import torch
from mmengine.config import ConfigDict
from mmengine.structures import InstanceData
from torch import Tensor
from mmdeploy.codebase.mmdet import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER, mark
from mmdeploy.mmcv.ops import multiclass_nms
from m... | Rewrite `predict_by_feat` of RTMDetHead for ncnn backend. 1. Decode the prior to a box format for ncnn DetectionOutput layer to do the post-processing. 2. Batch dimension is not supported by ncnn, but supported by pytorch. The negative value of axis in torch.cat is rewritten as corresponding positive value to avoid axi... |
188,679 | from typing import List, Optional
import torch
import torch.nn.functional as F
from mmengine.config import ConfigDict
from torch import Tensor
from mmdeploy.codebase.mmdet import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.mmcv.ops.nms import multiclass_nms
def _nms_with_mask_st... | Rewrite `predict_by_feat` of `RTMDet-Ins` for default backend. Rewrite this function to deploy model, transform network output for a batch into bbox predictions. Args: ctx: Context that contains original meta information. cls_scores (list[Tensor]): Classification scores for all scale levels, each is a 4D-tensor, has sh... |
188,680 | from typing import List, Optional
import torch
from mmdet.models.dense_heads import PAAHead
from mmdet.models.task_modules.coders import (DeltaXYWHBBoxCoder,
DistancePointBBoxCoder,
TBLRBBoxCoder)
from mmdet.structures.bbox impo... | Rewrite `predict_by_feat` of `BaseDenseHead` for default backend. Rewrite this function to deploy model, transform network output for a batch into bbox predictions. Args: ctx (ContextCaller): The context with additional information. cls_scores (list[Tensor]): Classification scores for all scale levels, each is a 4D-ten... |
188,681 | from typing import List, Optional
import torch
from mmdet.models.dense_heads import PAAHead
from mmdet.models.task_modules.coders import (DeltaXYWHBBoxCoder,
DistancePointBBoxCoder,
TBLRBBoxCoder)
from mmdet.structures.bbox impo... | Rewrite `predict_by_feat` of `BaseDenseHead` for default backend. Rewrite this function to deploy model, transform network output for a batch into bbox predictions. Args: ctx (ContextCaller): The context with additional information. cls_scores (list[Tensor]): Classification scores for all scale levels, each is a 4D-ten... |
188,682 | from typing import List, Optional
import torch
from mmdet.models.dense_heads import PAAHead
from mmdet.models.task_modules.coders import (DeltaXYWHBBoxCoder,
DistancePointBBoxCoder,
TBLRBBoxCoder)
from mmdet.structures.bbox impo... | Rewrite `predict_by_feat` of BaseDenseHead for ncnn backend. Shape node and batch inference is not supported by ncnn. This function transform dynamic shape to constant shape and remove batch inference. Args: ctx (ContextCaller): The context with additional information. cls_scores (list[Tensor]): Classification scores f... |
188,683 | from typing import List, Optional
import torch
import torch.nn.functional as F
from mmengine.config import ConfigDict
from mmengine.structures import InstanceData
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import (gather_topk,
get_post_processing_params,
... | Rewrite `predict_by_feat` of `GFLHead` for default backend. Rewrite this function to deploy model, transform network output for a batch into bbox predictions. Args: ctx (ContextCaller): The context with additional information. self (FoveaHead): The instance of the class FoveaHead. cls_scores (list[Tensor]): Box scores ... |
188,684 | import torch.nn.functional as F
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `base_semantic_head__predict` function. Write a Python function `def base_semantic_head__predict(self, x, batch_img_metas, rescale=False)` to solve the following pr... | Rewrite `predict` for default backend. Support configured dynamic/static shape for model input and return semantic-segmentation result as Tensor instead of numpy array. Args: x (Union[Tensor, Tuple[Tensor]]): Feature maps. batch_img_metas (List[dict]): List of image information. rescale (bool): Whether to rescale the r... |
188,685 | from typing import Tuple
import torch
from torch.onnx import symbolic_helper
from mmdeploy.core import FUNCTION_REWRITER
class GridPriorsTRTOp(torch.autograd.Function):
def forward(ctx, base_anchors, feat_h, feat_w, stride_h: int,
stride_w: int):
"""Generate grid priors by base anchors."""
... | This is a rewrite to replace ONNX anchor generator to TensorRT custom op. Args: ctx : The rewriter context featmap_size (tuple[int]): Size of the feature maps. level_idx (int): The index of corresponding feature map level. dtype (obj:`torch.dtype`): Date type of points.Defaults to ``torch.float32``. device (str, option... |
188,686 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils.constants import Backend
func_name='mmdet.models.task_modules.prior_generators.MlvlPointGenerator'
'.single_level_grid_priors',
backend=Backend.TENSORRT.value)
def mlvl_point_generator__single_level_grid_priors__tensorrt(
s... | Rewrite `single_level_grid_priors` of `MlvlPointGenerator` as onnx2tensorrt raise the error of shape inference for YOLOX with some versions of TensorRT. Args: featmap_size (tuple[int]): Size of the feature maps, arrange as (h, w). level_idx (int): The index of corresponding feature map level. dtype (:obj:`dtype`): Dtyp... |
188,687 | import numpy as np
import torch
from mmdeploy.core import FUNCTION_REWRITER
def delta2bbox(rois,
deltas,
means=(0., 0., 0., 0.),
stds=(1., 1., 1., 1.),
max_shape=None,
wh_ratio_clip=16 / 1000,
clip_border=True,
add_... | Rewrite `decode` of `DeltaXYWHBBoxCoder` for default backend. Rewrite this func to call `delta2bbox` directly. Args: bboxes (torch.Tensor): Basic boxes. Shape (B, N, 4) or (N, 4) pred_bboxes (Tensor): Encoded offsets with respect to each roi. Has shape (B, N, num_classes * 4) or (B, N, 4) or (N, num_classes * 4) or (N,... |
188,688 | import numpy as np
import torch
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `delta2bbox__ncnn` function. Write a Python function `def delta2bbox__ncnn(rois, deltas, means=(0., 0., 0., 0.), ... | Rewrite `delta2bbox` for ncnn backend. Batch dimension is not supported by ncnn, but supported by pytorch. ncnn regards the lowest two dimensions as continuous address with byte alignment, so the lowest two dimensions are not absolutely independent. Reshape operator with -1 arguments should operates ncnn::Mat with dime... |
188,689 | import mmdet.structures.bbox.transforms
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `distancepointbboxcoder__decode` function. Write a Python function `def distancepointbboxcoder__decode(self, points, pred_bboxes, max_shape=None)` to solve ... | Rewrite `mmdet.models.task_modules.coders.distance_point_bbox_coder. \ DistancePointBBoxCoder.decode` Decode distance prediction to bounding box. Args: ctx (ContextCaller): The context with additional information. self (DistancePointBBoxCoder): The instance of the class DistancePointBBoxCoder. points (Tensor): Shape (B... |
188,690 | import torch
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `tblr2bboxes` function. Write a Python function `def tblr2bboxes(priors, tblr, normalizer=4.0, normalize_by_wh=True, ma... | Rewrite `tblr2bboxes` for default backend. Since the need of clip op with dynamic min and max, this function uses clip_bboxes function to support dynamic shape. Args: ctx (ContextCaller): The context with additional information. priors (Tensor): Prior boxes in point form (x0, y0, x1, y1) Shape: (N,4) or (B, N, 4). tblr... |
188,691 | from typing import List, Optional, Tuple
import torch
import torch.nn.functional as F
from mmdet.structures.bbox import get_box_tensor
from mmengine import ConfigDict
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER, mark
from mmd... | Rewrite `forward` for default backend. This function uses the specific `forward` function for the BBoxHead or ConvFCBBoxHead after adding marks. Args: ctx (ContextCaller): The context with additional information. self: The instance of the original class. x (Tensor): Input image tensor. Returns: tuple(Tensor, Tensor): T... |
188,692 | from typing import List, Optional, Tuple
import torch
import torch.nn.functional as F
from mmdet.structures.bbox import get_box_tensor
from mmengine import ConfigDict
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER, mark
from mmd... | Rewrite `predict_by_feat` of `BBoxHead` for default backend. Transform network output for a batch into bbox predictions. Support `reg_class_agnostic == False` case. Args: rois (tuple[Tensor]): Tuple of boxes to be transformed. Each has shape (num_boxes, 5). last dimension 5 arrange as (batch_index, x1, y1, x2, y2). cls... |
188,693 | import torch
from mmcv.ops import RoIAlign
from torch.autograd import Function
from mmdeploy.core.optimizers import mark
from mmdeploy.core.rewriters import FUNCTION_REWRITER
from mmdeploy.utils import get_backend
from mmdeploy.utils.constants import Backend
class MultiLevelRoiAlign(Function):
"""Create MMCVMultiLe... | Rewrite `forward` of `SingleRoIExtractor` for TensorRT backend. This function uses MMCVMultiLevelRoiAlign op for TensorRT deployment. |
188,694 | import torch
from mmcv.ops import RoIAlign
from torch.autograd import Function
from mmdeploy.core.optimizers import mark
from mmdeploy.core.rewriters import FUNCTION_REWRITER
from mmdeploy.utils import get_backend
from mmdeploy.utils.constants import Backend
class AscendRoiExtractor(Function):
"""Create AscendRoiEx... | Rewrite `forward` of `SingleRoIExtractor` for Ascend backend. This function uses RoiExtractor op for Ascend deployment. |
188,695 | import torch
from mmcv.ops import RoIAlign
from torch.autograd import Function
from mmdeploy.core.optimizers import mark
from mmdeploy.core.rewriters import FUNCTION_REWRITER
from mmdeploy.utils import get_backend
from mmdeploy.utils.constants import Backend
class Backend(AdvancedEnum):
"""Define backend enumerati... | Rewrite `forward` of SingleRoIExtractor for default backend. Rewrite this function to: 1. enable exporting to IR even though the input image contains no targets. Note that, `ScatterND` of onnx may conflict with `Reshape` if a tensor have a dim size of 0. Thus, we have to cat zeros to the dim 0 of `roi_feats` and recove... |
188,696 | import torch
from mmcv.ops import RoIAlign
from torch.autograd import Function
from mmdeploy.core.optimizers import mark
from mmdeploy.core.rewriters import FUNCTION_REWRITER
from mmdeploy.utils import get_backend
from mmdeploy.utils.constants import Backend
class SingleRoIExtractorOpenVINO(Function):
"""This class... | Replaces SingleRoIExtractor with SingleRoIExtractorOpenVINO when exporting to OpenVINO. This function uses ExperimentalDetectronROIFeatureExtractor for OpenVINO. |
188,697 | import torch
from mmcv.ops import RoIAlign
from torch.autograd import Function
from mmdeploy.core.optimizers import mark
from mmdeploy.core.rewriters import FUNCTION_REWRITER
from mmdeploy.utils import get_backend
from mmdeploy.utils.constants import Backend
class Backend(AdvancedEnum):
"""Define backend enumerati... | Rewrite `forward` of SingleRoIExtractor for coreml. |
188,698 | from typing import List, Tuple
import torch
from mmdet.utils import ConfigType
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `standard_roi_head__predict_bbox` function. Write a Python function `def standard_roi_head__... | Rewrite `predict_bbox` of `StandardRoIHead` for default backend. Args: x (tuple[Tensor]): Feature maps of all scale level. batch_img_metas (list[dict]): List of image information. rpn_results_list (list[Tensor]): List of region proposals. rcnn_test_cfg (obj:`ConfigDict`): `test_cfg` of R-CNN. rescale (bool): If True, r... |
188,699 | from typing import List, Tuple
import torch
from mmdet.utils import ConfigType
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `standard_roi_head__predict_mask` function. Write a Python function `def standard_roi_head__... | Perform forward propagation of the mask head and predict detection results on the features of the upstream network. Args: x (tuple[Tensor]): Feature maps of all scale level. batch_img_metas (list[dict]): List of image information. results_list (list[:obj:`InstanceData`]): Detection results of each image. rescale (bool)... |
188,700 | from typing import List, Tuple
import torch
import torch.nn.functional as F
from mmengine import ConfigDict
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import Backend, get_backend
def _do_paste_mask(masks,... | Transform a batch of output features extracted from the head into mask results. Args: mask_preds (tuple[Tensor]): Tuple of predicted foreground masks, each has shape (n, num_classes, h, w). results_list (list[Tensor]): Detection results of each image. batch_img_metas (list[dict]): List of image information. rcnn_test_c... |
188,701 | from typing import List, Tuple
import torch
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
def htc_roi_head__predict_mask(self,
x: Tuple[Tensor],
semantic_heat: Tensor,
batch_img_metas: List[dict],
... | null |
188,702 | from typing import List, Tuple
import torch
from mmdet.structures.bbox import get_box_tensor
from mmdet.utils import ConfigType
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `cascade_roi_head__predict_bbox` function. ... | Rewrite `predict_bbox` of `CascadeRoIHead` for default backend. Args: x (tuple[Tensor]): Feature maps of all scale level. batch_img_metas (list[dict]): List of image information. rpn_results_list (list[Tensor]): List of region proposals. rcnn_test_cfg (obj:`ConfigDict`): `test_cfg` of R-CNN. rescale (bool): If True, re... |
188,703 | from typing import List, Tuple
import torch
from mmdet.structures.bbox import get_box_tensor
from mmdet.utils import ConfigType
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `cascade_roi_head__predict_mask` function. ... | Perform forward propagation of the mask head and predict detection results on the features of the upstream network. Args: x (tuple[Tensor]): Feature maps of all scale level. batch_img_metas (list[dict]): List of image information. results_list (list[Tensor]): Detection results of each image. rescale (bool): If True, re... |
188,704 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import Backend, get_root_logger
def l2norm__forward__default(self, x):
"""Default rewriter for l2norm.
Implement with functinoal.normalize .
"""
return torch.nn.functional.normalize(
x, dim=1) * self.weight[None, :, Non... | rewrite `l2norm` for TensorRT. TensorRT7 does not support dynamic clamp, which is used in normalize. |
188,705 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import is_dynamic_shape
The provided code snippet includes necessary dependencies for implementing the `maskformer__forward` function. Write a Python function `def maskformer__forward(self, batch_inputs, ... | Rewrite `forward` for default backend. Support configured dynamic/static shape for model input and return detection result as Tensor instead of numpy array. Args: batch_inputs (Tensor): Inputs with shape (N, C, H, W). batch_data_samples (List[:obj:`DetDataSample`]): The Data Samples. It usually includes information suc... |
188,706 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import is_dynamic_shape
The provided code snippet includes necessary dependencies for implementing the `two_stage_panoptic_segmentor__forward` function. Write a Python function `def two_stage_panoptic_segmentor__forward(self, ... | Rewrite `forward` for default backend. Support configured dynamic/static shape for model input and return detection result as Tensor instead of numpy array. Args: batch_inputs (Tensor): Inputs with shape (N, C, H, W). batch_data_samples (List[:obj:`DetDataSample`]): The Data Samples. It usually includes information suc... |
188,707 | import copy
import torch
from mmdet.models.detectors.base import ForwardResults
from mmdet.structures import DetDataSample
from mmdet.structures.det_data_sample import OptSampleList
from mmdeploy.core import FUNCTION_REWRITER, mark
from mmdeploy.utils import is_dynamic_shape
def __predict_impl(self, batch_inputs, data_... | Rewrite `predict` for default backend. Support configured dynamic/static shape for model input and return detection result as Tensor instead of numpy array. Args: batch_inputs (Tensor): Inputs with shape (N, C, H, W). data_samples (List[:obj:`DetDataSample`]): The Data Samples. It usually includes information such as `... |
188,708 | import torch
from mmdet.models.detectors.base import ForwardResults
from mmdet.structures import DetDataSample
from mmdet.structures.det_data_sample import OptSampleList
from mmdeploy.core import FUNCTION_REWRITER, mark
from mmdeploy.utils import is_dynamic_shape
def _set_metainfo(data_samples, img_shape):
The provide... | Rewrite `forward` for default backend. Support configured dynamic/static shape for model input and return detection result as Tensor instead of numpy array. Args: batch_inputs (Tensor): Inputs with shape (N, C, H, W). data_samples (List[:obj:`DetDataSample`]): The Data Samples. It usually includes information such as `... |
188,709 | import torch
from mmdet.models.detectors.base import ForwardResults
from mmdet.structures.det_data_sample import OptSampleList
from mmdeploy.core import FUNCTION_REWRITER, mark
from mmdeploy.utils import is_dynamic_shape
The provided code snippet includes necessary dependencies for implementing the `two_stage_detector... | Rewrite `extract_feat` for default backend. This function uses the specific `extract_feat` function for the two stage detector after adding marks. Args: ctx (ContextCaller): The context with additional information. self: The instance of the original class. img (Tensor | List[Tensor]): Input image tensor(s). Returns: li... |
188,710 | import torch
from mmdet.models.detectors.base import ForwardResults
from mmdet.structures.det_data_sample import OptSampleList
from mmdeploy.core import FUNCTION_REWRITER, mark
from mmdeploy.utils import is_dynamic_shape
The provided code snippet includes necessary dependencies for implementing the `two_stage_detector... | Rewrite `forward` for default backend. Support configured dynamic/static shape for model input and return detection result as Tensor instead of numpy array. Args: batch_inputs (Tensor): Inputs with shape (N, C, H, W). data_samples (List[:obj:`DetDataSample`]): The Data Samples. It usually includes information such as `... |
188,711 | import torch
from mmdet.models.detectors.base import ForwardResults
from mmdet.structures.det_data_sample import OptSampleList
from mmdeploy.core import FUNCTION_REWRITER, mark
from mmdeploy.utils import is_dynamic_shape
from .single_stage import _set_metainfo
def __forward_impl_instance_seg(self,
... | Rewrite `forward` for default backend. Support configured dynamic/static shape for model input and return detection result as Tensor instead of numpy array. Args: batch_inputs (Tensor): Inputs with shape (N, C, H, W). data_samples (List[:obj:`DetDataSample`]): The Data Samples. It usually includes information such as `... |
188,712 | import torch
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `get_topk_from_heatmap__default` function. Write a Python function `def get_topk_from_heatmap__default(scores, k=20)` to solve the following problem:
Get top k positions from heatmap.... | Get top k positions from heatmap. Replace view(batch, -1) with flatten |
188,713 | from copy import deepcopy
from typing import Dict, Optional, Sequence, Tuple, Union
import mmengine
import numpy as np
import torch
from mmdet3d.structures import get_box_type
from mmengine import Config
from mmengine.dataset import Compose, pseudo_collate
from mmengine.model import BaseDataPreprocessor
from mmdeploy.c... | Get metainfo of dataset. Args: model_cfg Config: Input model Config object. Returns: list[str]: A list of string specifying names of different class. |
188,714 | from typing import Any, Dict, List, Optional, Sequence, Union
import torch
from mmdet3d.structures.det3d_data_sample import SampleList
from mmengine import Config
from mmengine.model.base_model.data_preprocessor import BaseDataPreprocessor
from mmengine.registry import Registry
from mmengine.structures import BaseDataE... | Build monocular 3d object detection model for different backends. Args: model_files (Sequence[str]): Input model file(s). model_cfg (str | Config): Input model config file or Config object. deploy_cfg (str | Config): Input deployment config file or Config object. device (str): Device to input model data_preprocessor (B... |
188,715 | from typing import Any, Dict, List, Optional, Sequence, Union
import mmcv
import torch
from mmdet3d.structures.det3d_data_sample import SampleList
from mmengine import Config
from mmengine.model.base_model.data_preprocessor import BaseDataPreprocessor
from mmengine.registry import Registry
from mmengine.structures impo... | Build 3d voxel object detection model for different backends. Args: model_files (Sequence[str]): Input model file(s). model_cfg (str | Config): Input model config file or Config object. deploy_cfg (str | Config): Input deployment config file or Config object. device (str): Device to input model data_preprocessor (BaseD... |
188,716 | import os
from copy import deepcopy
from typing import Dict, Optional, Sequence, Tuple, Union
import mmengine
import numpy as np
import torch
from mmdet3d.structures import get_box_type
from mmengine import Config
from mmengine.dataset import Compose, pseudo_collate
from mmengine.model import BaseDataPreprocessor
from ... | Get metainfo of dataset. Args: model_cfg Config: Input model Config object. Returns: list[str]: A list of string specifying names of different class. |
188,717 | from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `singlestagemono3ddetector__forward` function. Write a Python function `def singlestagemono3ddetector__forward(self, inputs: Tensor, **kwargs)` to solve the following prob... | Rewrite to support feed inputs of Tensor type. Args: inputs (Tensor): Input image Returns: list: two torch.Tensor |
188,718 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import get_ir_config
The provided code snippet includes necessary dependencies for implementing the `mvxtwostagedetector__extract_img_feat` function. Write a Python function `def mvxtwostagedetector__extract_img_feat(self, img: torch.Tensor) ... | Extract features of images. |
188,719 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import get_ir_config
The provided code snippet includes necessary dependencies for implementing the `mvxtwostagedetector__extract_feat` function. Write a Python function `def mvxtwostagedetector__extract_feat(self, batch_inputs_dict: dict) ->... | Rewrite this func to remove voxelize op. Args: batch_inputs_dict (dict): Input dict comprises `voxels`, `num_points` and `coors` Returns: tuple(torch.Tensor) : image feature and points feather. |
188,720 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import get_ir_config
The provided code snippet includes necessary dependencies for implementing the `mvxtwostagedetector__forward` function. Write a Python function `def mvxtwostagedetector__forward(self, voxels: torch.Tensor, ... | Rewrite this func to remove voxelize op. Args: voxels (Tensor): input voxels num_points (Tensor): input num_points coors (Tensor): input coors Returns: tuple: A tuple of classification scores, bbox and direction classification prediction. - cls_scores (list[Tensor]): Classification scores for all scale levels, each is ... |
188,721 | import torch
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `pointpillarsscatter__forward` function. Write a Python function `def pointpillarsscatter__forward(self, voxel_features, coors, batch_size=1)` to solve the following problem:
Scatter ... | Scatter features of single sample. Args: voxel_features (torch.Tensor): Voxel features from voxel encoder layer. coors (torch.Tensor): Coordinates of each voxel. The first column indicates the sample ID. batch_size (int): Number of samples in the current batch, batch_size=1 by default. |
188,722 | from typing import List, Tuple
import torch
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `basedetector__forward` function. Write a Python function `def basedetector__forward(self, voxels: torch.Tensor, ... | Extract features of images. |
188,723 | import torch
from mmdet3d.models.voxel_encoders.utils import get_paddings_indicator
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `pillar_encoder__forward` function. Write a Python function `def pillar_encoder__forward(self, features, num_poi... | Rewrite this func to optimize node. Modify the code at _with_voxel_center and use slice instead of the original operation. Args: features (torch.Tensor): Point features or raw points in shape (N, M, C). num_points (torch.Tensor): Number of points in each pillar. coors (torch.Tensor): Coordinates of each voxel. Returns:... |
188,724 | from typing import List, Optional, Sequence, Union
import mmengine
import torch
from mmagic.structures import DataSample
from mmengine import Config
from mmengine.model.base_model.data_preprocessor import BaseDataPreprocessor
from mmengine.registry import Registry
from mmengine.structures import BaseDataElement
from to... | Build super resolution model for different backends. Args: model_files (Sequence[str]): Input model file(s). model_cfg (str | Config): Input model config file or Config object. deploy_cfg (str | Config): Input deployment config file or Config object. device (str): Device to input model data_preprocessor (BaseDataPrepro... |
188,725 | from copy import deepcopy
from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Union
import mmengine
import numpy as np
import torch
from mmengine import Config
from mmengine.dataset import pseudo_collate
from mmengine.model import BaseDataPreprocessor
from mmdeploy.codebase.base import BaseTask
from mmde... | Process the model config. Args: model_cfg (mmengine.Config): The model config. imgs (Sequence[str] | Sequence[np.ndarray]): Input image(s), accepted data type are List[str], List[np.ndarray]. input_shape (list[int]): A list of two integer in (width, height) format specifying input shape. Default: None. Returns: mmengin... |
188,726 | from copy import deepcopy
from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Union
import mmengine
import numpy as np
import torch
from mmengine import Config
from mmengine.dataset import pseudo_collate
from mmengine.model import BaseDataPreprocessor
from mmdeploy.codebase.base import BaseTask
from mmde... | Get metainfo of dataset. Args: model_cfg Config: Input model Config object. Returns: list[str]: A list of string specifying names of different class. |
188,727 |
The provided code snippet includes necessary dependencies for implementing the `base_edit_model__forward` function. Write a Python function `def base_edit_model__forward( self, batch_inputs: Tensor, data_samples: Optional[List[BaseDataElement]] = None, mode: str = 'predict')` to solve ... | Rewrite `forward` of BaseEditModel for default backend. Args: batch_inputs (torch.Tensor): The input tensor with shape (N, C, ...) in general. data_samples (List[BaseDataElement], optional): The annotation data of every samples. It's required if ``mode="loss"``. Defaults to None. mode (str): Return what kind of value. ... |
188,728 | from copy import deepcopy
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import mmengine
import numpy as np
import torch
from mmengine import Config
from mmengine.dataset import pseudo_collate
from mmengine.dist import cast_data_device
from mmengine.model import BaseDataPreprocessor
from mmdeploy.c... | Process the model config. Args: model_cfg (mmengine.Config): The model config. imgs (Sequence[str] | Sequence[np.ndarray]): Input image(s), accepted data type are List[str], List[np.ndarray]. input_shape (list[int]): A list of two integer in (width, height) format specifying input shape. Default: None. Returns: mmengin... |
188,729 | from copy import deepcopy
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import mmengine
import numpy as np
import torch
from mmengine import Config
from mmengine.dataset import pseudo_collate
from mmengine.dist import cast_data_device
from mmengine.model import BaseDataPreprocessor
from mmdeploy.c... | Get metainfo of dataset. Args: model_cfg Config: Input model Config object. Returns: list[str]: A list of string specifying names of different class. |
188,730 | from typing import List, Optional, Sequence, Union
import cv2
import mmengine
import torch
from mmengine.registry import Registry
from mmengine.structures import BaseDataElement, InstanceData
from mmocr.structures import TextDetDataSample
from mmdeploy.codebase.base import BaseBackendModel
from mmdeploy.utils import (B... | Build text detection model for different backends. Args: model_files (Sequence[str]): Input model file(s). model_cfg (str | mmengine.Config): Input model config file or Config object. deploy_cfg (str | mmengine.Config): Input deployment config file or Config object. device (str): Device to input model. Returns: BaseBac... |
188,731 | from typing import Optional, Sequence, Union
import mmengine
import torch
from mmengine.registry import Registry
from mmengine.structures import LabelData
from mmocr.utils.typing_utils import RecSampleList
from mmdeploy.codebase.base import BaseBackendModel
from mmdeploy.utils import (Backend, get_backend, get_codebase... | Build text recognition model for different backends. Args: model_files (Sequence[str]): Input model file(s). model_cfg (str | mmengine.Config): Input model config file or Config object. deploy_cfg (str | mmengine.Config): Input deployment config file or Config object. device (str): Device to input model. Returns: BaseB... |
188,732 | from copy import deepcopy
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import mmengine
import numpy as np
import torch
from mmengine import Config
from mmengine.dataset import pseudo_collate
from mmengine.dist import cast_data_device
from mmengine.model import BaseDataPreprocessor
from mmdeploy.c... | Process the model config. Args: model_cfg (mmengine.Config): The model config. imgs (Sequence[str] | Sequence[np.ndarray]): Input image(s), accepted data type are List[str], List[np.ndarray]. input_shape (list[int]): A list of two integer in (width, height) format specifying input shape. Default: None. Returns: mmengin... |
188,733 | from copy import deepcopy
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import mmengine
import numpy as np
import torch
from mmengine import Config
from mmengine.dataset import pseudo_collate
from mmengine.dist import cast_data_device
from mmengine.model import BaseDataPreprocessor
from mmdeploy.c... | Get metainfo of dataset. Args: model_cfg Config: Input model Config object. Returns: list[str]: A list of string specifying names of different class. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.