本文整理汇总了Python中mmdet.datasets.transforms.ImageTransform方法的典型用法代码示例。如果您正苦于以下问题:Python transforms.ImageTransform方法的具体用法?Python transforms.ImageTransform怎么用?Python transforms.ImageTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mmdet.datasets.transforms
的用法示例。
在下文中一共展示了transforms.ImageTransform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: inference_detector
# 需要导入模块: from mmdet.datasets import transforms [as 别名]
# 或者: from mmdet.datasets.transforms import ImageTransform [as 别名]
def inference_detector(model, imgs):
"""Inference image(s) with the detector.
Args:
model (nn.Module): The loaded detector.
imgs (str/ndarray or list[str/ndarray]): Either image files or loaded
images.
Returns:
If imgs is a str, a generator will be returned, otherwise return the
detection results directly.
"""
cfg = model.cfg
img_transform = ImageTransform(
size_divisor=cfg.data.test.size_divisor, **cfg.img_norm_cfg)
device = next(model.parameters()).device # model device
if not isinstance(imgs, list):
return _inference_single(model, imgs, img_transform, device)
else:
return _inference_generator(model, imgs, img_transform, device)
示例2: inference_detector
# 需要导入模块: from mmdet.datasets import transforms [as 别名]
# 或者: from mmdet.datasets.transforms import ImageTransform [as 别名]
def inference_detector(model, imgs, cfg, device='cuda:0'):
img_transform = ImageTransform(
size_divisor=cfg.data.test.size_divisor, **cfg.img_norm_cfg)
model = model.to(device)
model.eval()
if not isinstance(imgs, list):
return _inference_single(model, imgs, img_transform, cfg, device)
else:
return _inference_generator(model, imgs, img_transform, cfg, device)