File size: 1,634 Bytes
954caab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a65ed45
 
 
 
 
 
 
 
 
 
 
 
 
954caab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from pathlib import Path
from PIL import Image
import numpy as np

from .view_identity import IdentityView
from .view_flip import FlipView
from .view_rotate import Rotate180View, Rotate90CCWView, Rotate90CWView
from .view_negate import NegateView
from .view_skew import SkewView
from .view_patch_permute import PatchPermuteView
from .view_jigsaw import JigsawView
from .view_inner_circle import InnerCircleView

VIEW_MAP = {
    'identity': IdentityView,
    'flip': FlipView,
    'rotate_cw': Rotate90CWView,
    'rotate_ccw': Rotate90CCWView,
    'rotate_180': Rotate180View,
    'negate': NegateView,
    'skew': SkewView,
    'patch_permute': PatchPermuteView,
    'pixel_permute': PatchPermuteView,
    'jigsaw': JigsawView,
    'inner_circle': InnerCircleView,
}

VIEW_MAP_NAMES = {
    'Flip': 'flip',
    'Rotate 90° clockwise': 'rotate_cw',
    'Rotate 90° counter-clockwise': 'rotate_ccw',
    'Rotate 180°': 'rotate_180',
    'Invert colors': 'negate',
    'Shear': 'skew',
    'Patch permutation': 'patch_permute',
    'Pixel permutation': 'pixel_permute',
    'Jigsaw permutation': 'jigsaw',
    'Rotate inner circle': 'inner_circle',
}

def get_views(view_names):
    '''
    Bespoke function to get views (just to make command line usage easier)
    '''
    views = []
    for view_name in view_names:
        if view_name == 'patch_permute':
            args = [8]
        elif view_name == 'pixel_permute':
            args = [64]
        elif view_name == 'skew':
            args = [1.5]
        else:
            args = []

        view = VIEW_MAP[view_name](*args)
        views.append(view)

    return views