第二次大修

This commit is contained in:
Jiao77
2025-06-08 15:38:56 +08:00
parent 53ef1ec99c
commit f0b2e1b605
10 changed files with 315 additions and 508 deletions

0
utils/__init__.py Normal file
View File

14
utils/data_utils.py Normal file
View File

@@ -0,0 +1,14 @@
from torchvision import transforms
from .transforms import SobelTransform
def get_transform():
"""
获取统一的图像预处理管道。
确保训练、评估和推理使用完全相同的预处理。
"""
return transforms.Compose([
SobelTransform(), # 应用 Sobel 边缘检测
transforms.ToTensor(),
transforms.Lambda(lambda x: x.repeat(3, 1, 1)), # 适配 VGG 的三通道输入
transforms.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])
])