python-3.x - 如何恢复在 DataLoader 中应用的转换?

标签 python-3.x pytorch torchvision

我们定义了一些 DataSet 和一些随机的 transform ,每次加载特定图像时都会重新应用这些 transform 。是否也可以用图像提取应用于图像的变换? (我也想将应用于图像的转换应用到其他图像。)

import torchvision
import torchvision.transforms as transforms
import torch.utils.data

path = "/path/to/image/folders/" #should contain at least one folder with some images
transform = transforms.Compose([
    transforms.RandomHorizontalFlip(p=0.5),
    transforms.RandomRotation(degrees=[0, 360]),
    transforms.ToTensor()
])
dataset = torchvision.datasets.ImageFolder(root=path, transform=transform)

dataloader = torch.utils.data.DataLoader(dataset=dataset, shuffle=True)

for input, target in dataloader:
    pass #get transform that was applied to input?

最佳答案

我认为没有 API 可以获取应用的转换。

您能否重新实现随机转换的 __call__ 方法,以便它们也记录所应用的内容? (只有几行:https://pytorch.org/docs/stable/_modules/torchvision/transforms/transforms.html#RandomHorizontalFlip)

关于python-3.x - 如何恢复在 DataLoader 中应用的转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56008135/

相关文章:

python - Pytorch 相当于 Numpy 的 logical_and 和 kin?

pytorch - 在训练模式下 DeepLabV3 的输入应该是什么?

python - 有什么方法可以将 PyTorch 中可用的预训练模型下载到特定路径?

python-3.x - Python Pandas 数据框列无法在分割数据部分上正确更新

python - 如何在 Python 3.6 中验证 AWS Cognito 生成的 JWT 的签名?

deep-learning - 如何在pytorch中连接嵌入层

python - 如何使用 torch.hub.load 加载本地模型?

django - 在 django 项目中使用 xhtml2pdf 从 html 生成 pdf

python - 按单个字符分组,否则拆分

pytorch - 如何在 PyTorch 中进行批量点积?