|
6 | 6 | |_| |_|\___|\__,_|_| \__,_|_| \__\___/_/\_\\__|\__,_|_| |_/___\___| |
7 | 7 |
|
8 | 8 | Usage: |
| 9 | + texturize SOURCE... [--size=WxH] [--output=FILE] [--seed=SEED] [--device=DEVICE] |
9 | 10 | [--octaves=O] [--precision=P] [--iterations=I] |
10 | 11 | texturize --help |
11 | 12 |
|
|
18 | 19 | Options: |
19 | 20 | SOURCE Path to source image to use as texture. |
20 | 21 | -s WxH, --size=WxH Output resolution as WIDTHxHEIGHT. [default: 640x480] |
| 22 | + --seed=SEED Configure the random number generation. |
21 | 23 | --device=DEVICE Hardware to use, either "cpu" or "cuda". |
22 | 24 | --octaves=O Number of octaves to process. [default: 5] |
23 | 25 | --precision=P Set the quality for the optimization. [default: 1e-4] |
@@ -96,7 +98,7 @@ def _prepare_gram(self, features): |
96 | 98 |
|
97 | 99 |
|
98 | 100 | def get_all_layers(critics): |
99 | | - """Determine the minimal list of layer features that needs to be extracted from the image. |
| 101 | + """Determine the minimal list of features that needs to be extracted from the image. |
100 | 102 | """ |
101 | 103 | layers = set(itertools.chain.from_iterable(c.get_layers() for c in critics)) |
102 | 104 | return sorted(list(layers)) |
@@ -323,6 +325,13 @@ def main(): |
323 | 325 | # Scan all the files based on the patterns specified. |
324 | 326 | files = itertools.chain.from_iterable(glob.glob(s) for s in config["SOURCE"]) |
325 | 327 | for filename in files: |
| 328 | + # If there's a random seed, use it for all images. |
| 329 | + if config["--seed"] is not None: |
| 330 | + seed = int(config["--seed"]) |
| 331 | + torch.manual_seed(seed) |
| 332 | + torch.cuda.manual_seed(seed) |
| 333 | + |
| 334 | + # By default, disable autograd until the core optimization loop. |
326 | 335 | with torch.no_grad(): |
327 | 336 | try: |
328 | 337 | run(config, filename) |
|
0 commit comments