Files
RoRD-Layout-Recognation/utils/data_utils.py

14 lines
531 B
Python
Raw Normal View History

2025-06-08 15:38:56 +08:00
from torchvision import transforms
from .transforms import SobelTransform
def get_transform():
"""
2025-07-22 23:43:35 +08:00
Get unified image preprocessing pipeline.
Ensure training, evaluation, and inference use exactly the same preprocessing.
2025-06-08 15:38:56 +08:00
"""
return transforms.Compose([
2025-07-22 23:43:35 +08:00
SobelTransform(), # Apply Sobel edge detection
2025-06-08 15:38:56 +08:00
transforms.ToTensor(),
2025-07-22 23:43:35 +08:00
transforms.Lambda(lambda x: x.repeat(3, 1, 1)), # Adapt to VGG's three-channel input
2025-06-08 15:38:56 +08:00
transforms.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])
])