This function will compute a new size and update it on the next mini_batch. Args: multiple (int or tuple, optional): values to multiply the randomly generated range by. Default **32** random_range (tuple, optional): This (min, max) tuple sets the rang
(self, multiple=32, random_range=(10, 19))
| 121 | self.batch_sampler.mosaic = False |
| 122 | |
| 123 | def change_input_dim(self, multiple=32, random_range=(10, 19)): |
| 124 | """This function will compute a new size and update it on the next mini_batch. |
| 125 | |
| 126 | Args: |
| 127 | multiple (int or tuple, optional): values to multiply the randomly generated range by. |
| 128 | Default **32** |
| 129 | random_range (tuple, optional): This (min, max) tuple sets the range |
| 130 | for the randomisation; Default **(10, 19)** |
| 131 | |
| 132 | Return: |
| 133 | tuple: width, height tuple with new dimension |
| 134 | |
| 135 | Note: |
| 136 | The new size is generated as follows: |br| |
| 137 | First we compute a random integer inside ``[random_range]``. |
| 138 | We then multiply that number with the ``multiple`` argument, |
| 139 | which gives our final new input size. |br| |
| 140 | If ``multiple`` is an integer we generate a square size. If you give a tuple |
| 141 | of **(width, height)**, the size is computed |
| 142 | as :math:`rng * multiple[0], rng * multiple[1]`. |
| 143 | |
| 144 | Note: |
| 145 | You can set the ``random_range`` argument to **None** to set |
| 146 | an exact size of multiply. |br| |
| 147 | See the example above for how this works. |
| 148 | """ |
| 149 | if random_range is None: |
| 150 | size = 1 |
| 151 | else: |
| 152 | size = random.randint(*random_range) |
| 153 | |
| 154 | if isinstance(multiple, int): |
| 155 | size = (size * multiple, size * multiple) |
| 156 | else: |
| 157 | size = (size * multiple[0], size * multiple[1]) |
| 158 | |
| 159 | self.batch_sampler.new_input_dim = size |
| 160 | |
| 161 | return size |
| 162 | |
| 163 | |
| 164 | def list_collate(batch): |
no outgoing calls
no test coverage detected