本文整理匯總了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)