You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@register
class Compose(T.Compose):
def init(self, ops) -> None:
transforms = []
if ops is not None:
for op in ops:
if isinstance(op, dict):
name = op.pop('type')
transfom = getattr(GLOBAL_CONFIG[name]['_pymodule'], name)(**op)
transforms.append(transfom)
# op['type'] = name
elif isinstance(op, nn.Module):
transforms.append(op)
`""""by lyuwenyu
"""
import torch
import torch.nn as nn
import torchvision
torchvision.disable_beta_transforms_warning()
from torchvision import datapoints
import torchvision.transforms.v2 as T
import torchvision.transforms.v2.functional as F
from PIL import Image
from typing import Any, Dict, List, Optional
from src.core import register, GLOBAL_CONFIG
all = ['Compose', ]
RandomPhotometricDistort = register(T.RandomPhotometricDistort)
RandomZoomOut = register(T.RandomZoomOut)
RandomIoUCrop = register(T.RandomIoUCrop)
RandomHorizontalFlip = register(T.RandomHorizontalFlip)
Resize = register(T.Resize)
ToImageTensor = register(T.ToImageTensor)
ConvertDtype = register(T.ConvertDtype)
SanitizeBoundingBox = register(T.SanitizeBoundingBox)
RandomCrop = register(T.RandomCrop)
Normalize = register(T.Normalize)
@register
class Compose(T.Compose):
def init(self, ops) -> None:
transforms = []
if ops is not None:
for op in ops:
if isinstance(op, dict):
name = op.pop('type')
transfom = getattr(GLOBAL_CONFIG[name]['_pymodule'], name)(**op)
transforms.append(transfom)
# op['type'] = name
elif isinstance(op, nn.Module):
transforms.append(op)
@register
class EmptyTransform(T.Transform):
def init(self, ) -> None:
super().init()
@register
class PadToSize(T.Pad):
_transformed_types = (
Image.Image,
datapoints.Image,
datapoints.Video,
datapoints.Mask,
datapoints.BoundingBox,
)
@register
class RandomIoUCrop(T.RandomIoUCrop):
def init(self, min_scale: float = 0.3, max_scale: float = 1, min_aspect_ratio: float = 0.5,
max_aspect_ratio: float = 2, sampler_options: Optional[List[float]] = None, trials: int = 40,
p: float = 1.0):
super().init(min_scale, max_scale, min_aspect_ratio, max_aspect_ratio, sampler_options, trials)
self.p = p
@register
class ConvertBox(T.Transform):
_transformed_types = (
datapoints.BoundingBox,
)
作者你好,感谢你对RT-DETR的工作,目前我的代码能力不是特别厉害暂时梳理不清这个数据预处理的过程,能麻烦作者帮理一下在pytroch中,数据预处理的过程吗,是先将图片处理成640x640再转tensor吗,转化的过程具体用了什么方法呢?用不同的数据预处理方法对图片推理的时候有影响吗?
The text was updated successfully, but these errors were encountered: