vipsim 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
vipsim/__init__.py ADDED
@@ -0,0 +1,84 @@
1
+ """VipSim: visual-impairment simulation filters.
2
+
3
+ A NumPy/PIL port of the VIP-Sim Unity shaders (https://github.com/Max-Raed/VIP-Sim).
4
+ The PyTorch backend lives in `vipsim.gpu`. `VipSimGPU` and
5
+ `VisualImpairmentWrapper` are also reachable from here, but only load torch
6
+ on first access, so `import vipsim` neither requires torch nor pays for
7
+ importing it.
8
+ """
9
+
10
+ __version__ = "0.1.0"
11
+
12
+ from .filters import ( # noqa: F401
13
+ CVD_MATRICES,
14
+ PRESETS,
15
+ apply_bcg,
16
+ apply_bloom,
17
+ apply_blur,
18
+ apply_cataracts,
19
+ apply_cvd,
20
+ apply_detail_loss,
21
+ apply_distortion,
22
+ apply_double_vision,
23
+ apply_field_loss,
24
+ apply_flickering_stars,
25
+ apply_floaters,
26
+ apply_foveal_darkness,
27
+ apply_glitch,
28
+ apply_led,
29
+ apply_noise,
30
+ apply_nystagmus,
31
+ apply_pixelation,
32
+ apply_preset,
33
+ apply_teichopsia,
34
+ apply_vignette,
35
+ apply_vortex,
36
+ apply_wiggle,
37
+ )
38
+
39
+ __all__ = [
40
+ "CVD_MATRICES",
41
+ "PRESETS",
42
+ "apply_bcg",
43
+ "apply_bloom",
44
+ "apply_blur",
45
+ "apply_cataracts",
46
+ "apply_cvd",
47
+ "apply_detail_loss",
48
+ "apply_distortion",
49
+ "apply_double_vision",
50
+ "apply_field_loss",
51
+ "apply_flickering_stars",
52
+ "apply_floaters",
53
+ "apply_foveal_darkness",
54
+ "apply_glitch",
55
+ "apply_led",
56
+ "apply_noise",
57
+ "apply_nystagmus",
58
+ "apply_pixelation",
59
+ "apply_preset",
60
+ "apply_teichopsia",
61
+ "apply_vignette",
62
+ "apply_vortex",
63
+ "apply_wiggle",
64
+ ]
65
+
66
+ # Re-exported from vipsim.gpu on first access (PEP 562): torch is optional and
67
+ # slow to import. Not in __all__, so `from vipsim import *` never needs torch.
68
+ _GPU_EXPORTS = ("VipSimGPU", "VisualImpairmentWrapper")
69
+
70
+
71
+ def __getattr__(name):
72
+ if name in _GPU_EXPORTS:
73
+ try:
74
+ from . import gpu
75
+ except ImportError as e:
76
+ raise ImportError(
77
+ f"vipsim.{name} needs PyTorch: pip install 'vipsim[gpu]' ({e})"
78
+ ) from e
79
+ return getattr(gpu, name)
80
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
81
+
82
+
83
+ def __dir__():
84
+ return sorted(list(globals()) + list(_GPU_EXPORTS))
vipsim/__main__.py ADDED
@@ -0,0 +1,4 @@
1
+ """`python -m vipsim ...` runs the command-line interface."""
2
+ from .filters import main
3
+
4
+ main()
Binary file