3 This is a port of the Synthetic Visual Reasoning Test problems to the
4 pytorch framework, with an implementation of two convolutional
5 networks to solve them.
7 # Installation and test #
16 should generate an image
17 [`example.png`](https://fleuret.org/git-extract/pysvrt/example.png) in
18 the current directory.
20 Note that the image generation does not take advantage of GPUs or
21 multi-core, and can be as fast as 10,000 vignettes per second and as
22 slow as 40 on a 4GHz i7-6700K.
24 # Vignette generation and compression #
28 The file [`svrtset.py`](https://fleuret.org/git-extract/pysvrt/svrtset.py) implements the classes `VignetteSet` and
29 `CompressedVignetteSet` with the following constructor
32 __init__(problem_number, nb_samples, batch_size, cuda = False, logger = None)
35 and the following method to return one batch
38 (torch.FloatTensor, torch.LongTensor) get_batch(b)
41 as a pair composed of a 4d 'input' Tensor (i.e. single channel 128x128
42 images), and a 1d 'target' Tensor (i.e. Boolean labels).
44 ## Low-level functions ##
46 The main function for genering vignettes is
49 torch.ByteTensor svrt.generate_vignettes(int problem_number, torch.LongTensor labels)
54 * `problem_number` indicates which of the 23 problem to use
55 * `labels` indicates the boolean labels of the vignettes to generate
57 The returned ByteTensor has three dimensions:
63 The two additional functions
66 torch.ByteStorage svrt.compress(torch.ByteStorage x)
72 torch.ByteStorage svrt.uncompress(torch.ByteStorage x)
75 provide a lossless compression scheme adapted to the ByteStorage of
76 the vignette ByteTensor (i.e. expecting a lot of 255s, a few 0s, and
79 This compression reduces the memory footprint by a factor ~50, and may
80 be usefull to deal with very large data-sets and avoid re-generating
81 images at every batch. It induces a little overhead for decompression,
82 and moving from CPU to GPU memory.
84 See vignette_set.py for a class CompressedVignetteSet using it.
86 # Testing convolution networks #
89 [`cnn-svrt.py`](https://fleuret.org/git-extract/pysvrt/cnn-svrt.py)
90 provides the implementation of two deep networks designed by Afroze
91 Baqapuri during an internship at Idiap, and allows to train them with
92 several millions vignettes on a PC with 16Gb and a GPU with 8Gb.