aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Gong <jordan.gong@protonmail.com>2022-07-14 17:43:22 +0800
committerJordan Gong <jordan.gong@protonmail.com>2022-07-14 17:43:22 +0800
commitcf14b84aa81c1996cf29a4fdb2b3a00fe546c388 (patch)
treedc54bc5377d8fa8101c8025c2c6509ec40d13313
parent2cc459e3e4b2d559b5d8aa757c694db02ccd0e2a (diff)
Add Siamese transform wrapper
-rw-r--r--libs/datautils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/libs/datautils.py b/libs/datautils.py
index feae481..6a7c506 100644
--- a/libs/datautils.py
+++ b/libs/datautils.py
@@ -115,3 +115,13 @@ class MultiCropDatasetWrapper(Dataset):
multi_crops = list(map(lambda trans: trans(img), self.transform))
return multi_crops, target
+
+
+class TwinTransform:
+ def __init__(self, transform):
+ self.transform = transform
+
+ def __call__(self, x):
+ v1 = self.transform(x)
+ v2 = self.transform(x)
+ return v1, v2