aboutsummaryrefslogtreecommitdiff
path: root/supervised/datautils.py
diff options
context:
space:
mode:
authorJordan Gong <jordan.gong@protonmail.com>2022-03-16 17:49:51 +0800
committerJordan Gong <jordan.gong@protonmail.com>2022-03-16 17:49:51 +0800
commit5869d0248fa958acd3447e6bffa8761b91e8e921 (patch)
tree4e2c0744400d9204bdfd23c58bafcf534c2119fb /supervised/datautils.py
parent608178533e93dc7e6fac6059fa139233ab046b63 (diff)
Regular refactoring
Diffstat (limited to 'supervised/datautils.py')
-rw-r--r--supervised/datautils.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/supervised/datautils.py b/supervised/datautils.py
new file mode 100644
index 0000000..196fca7
--- /dev/null
+++ b/supervised/datautils.py
@@ -0,0 +1,13 @@
+from torchvision.transforms import transforms
+
+
+def color_distortion(s=1.0):
+ # s is the strength of color distortion.
+ color_jitter = transforms.ColorJitter(0.8 * s, 0.8 * s, 0.8 * s, 0.2 * s)
+ rnd_color_jitter = transforms.RandomApply([color_jitter], p=0.8)
+ rnd_gray = transforms.RandomGrayscale(p=0.2)
+ color_distort = transforms.Compose([
+ rnd_color_jitter,
+ rnd_gray
+ ])
+ return color_distort