easycv.models.detection.yolox package

Submodules

easycv.models.detection.yolox.yolo_head module

class easycv.models.detection.yolox.yolo_head.YOLOXHead(num_classes, width=1.0, strides=[8, 16, 32], in_channels=[256, 512, 1024], act='silu', depthwise=False, stage='CLOUD')[source]

Bases: torch.nn.modules.module.Module

__init__(num_classes, width=1.0, strides=[8, 16, 32], in_channels=[256, 512, 1024], act='silu', depthwise=False, stage='CLOUD')[source]
Parameters
  • num_classes (int) – detection class numbers.

  • width (float) – model width. Default value: 1.0.

  • strides (list) – expanded strides. Default value: [8, 16, 32].

  • in_channels (list) – model conv channels set. Default value: [256, 512, 1024].

  • act (str) – activation type of conv. Defalut value: “silu”.

  • depthwise (bool) – whether apply depthwise conv in conv branch. Default value: False.

  • stage (str) – model stage, distinguish edge head to cloud head. Default value: CLOUD.

initialize_biases(prior_prob)[source]
forward(xin, labels=None, imgs=None)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

get_output_and_grid(output, k, stride, dtype)[source]
decode_outputs(outputs, dtype)[source]
get_losses(imgs, x_shifts, y_shifts, expanded_strides, labels, outputs, origin_preds, dtype)[source]
get_l1_target(l1_target, gt, stride, x_shifts, y_shifts, eps=1e-08)[source]
get_assignments(batch_idx, num_gt, total_num_anchors, gt_bboxes_per_image, gt_classes, bboxes_preds_per_image, expanded_strides, x_shifts, y_shifts, cls_preds, bbox_preds, obj_preds, labels, imgs, mode='gpu')[source]
get_in_boxes_info(gt_bboxes_per_image, expanded_strides, x_shifts, y_shifts, total_num_anchors, num_gt)[source]
dynamic_k_matching(cost, pair_wise_ious, gt_classes, num_gt, fg_mask)[source]
training: bool

easycv.models.detection.yolox.yolo_pafpn module

class easycv.models.detection.yolox.yolo_pafpn.YOLOPAFPN(depth=1.0, width=1.0, in_features=('dark3', 'dark4', 'dark5'), in_channels=[256, 512, 1024], depthwise=False, act='silu')[source]

Bases: torch.nn.modules.module.Module

YOLOv3 model. Darknet 53 is the default backbone of this model.

__init__(depth=1.0, width=1.0, in_features=('dark3', 'dark4', 'dark5'), in_channels=[256, 512, 1024], depthwise=False, act='silu')[source]

Initializes internal Module state, shared by both nn.Module and ScriptModule.

forward(input)[source]
Parameters

inputs – input images.

Returns

FPN feature.

Return type

Tuple[Tensor]

training: bool

easycv.models.detection.yolox.yolox module

easycv.models.detection.yolox.yolox.init_yolo(M)[source]
class easycv.models.detection.yolox.yolox.YOLOX(model_type: str = 's', num_classes: int = 80, test_size: tuple = (640, 640), test_conf: float = 0.01, nms_thre: float = 0.65, pretrained: Optional[str] = None)[source]

Bases: easycv.models.base.BaseModel

YOLOX model module. The module list is defined by create_yolov3_modules function. The network returns loss values from three YOLO layers during training and detection results during test.

param_map = {'l': [1.0, 1.0], 'm': [0.67, 0.75], 'nano': [0.33, 0.25], 's': [0.33, 0.5], 'tiny': [0.33, 0.375], 'x': [1.33, 1.25]}
__init__(model_type: str = 's', num_classes: int = 80, test_size: tuple = (640, 640), test_conf: float = 0.01, nms_thre: float = 0.65, pretrained: Optional[str] = None)[source]

Initializes internal Module state, shared by both nn.Module and ScriptModule.

forward_train(img: torch.Tensor, gt_bboxes: torch.Tensor, gt_labels: torch.Tensor, img_metas=None, scale=None)Dict[str, torch.Tensor][source]

Abstract interface for model forward in training

Parameters
  • img (Tensor) – image tensor, NxCxHxW

  • target (List[Tensor]) – list of target tensor, NTx5 [class,x_c,y_c,w,h]

forward_test(img: torch.Tensor, img_metas=None)torch.Tensor[source]

Abstract interface for model forward in training

Parameters
  • img (Tensor) – image tensor, NxCxHxW

  • target (List[Tensor]) – list of target tensor, NTx5 [class,x_c,y_c,w,h]

forward(img, mode='compression', **kwargs)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

forward_compression(x)[source]
forward_export(img)[source]
training: bool