Cropinky commited on
Commit
94e98b0
1 Parent(s): b422fa9
Files changed (2) hide show
  1. app.py +2 -2
  2. image_generator.py +4 -9
app.py CHANGED
@@ -6,11 +6,11 @@ import torchvision
6
  from networks_fastgan import MyGenerator
7
  import click
8
  import PIL
9
-
10
-
11
 
12
  def image_generation(model, number_of_images=1):
13
  G = MyGenerator.from_pretrained("Cropinky/projected_gan_impressionism")
 
14
  return f"generating {number_of_images} images from {model}"
15
  if __name__ == "__main__":
16
 
 
6
  from networks_fastgan import MyGenerator
7
  import click
8
  import PIL
9
+ from image_generator import generate_images
 
10
 
11
  def image_generation(model, number_of_images=1):
12
  G = MyGenerator.from_pretrained("Cropinky/projected_gan_impressionism")
13
+ generate_images(seeds = 10-15, outdir="out")
14
  return f"generating {number_of_images} images from {model}"
15
  if __name__ == "__main__":
16
 
image_generator.py CHANGED
@@ -11,13 +11,11 @@
11
  import os
12
  import re
13
  from typing import List, Optional, Tuple, Union
14
-
15
  import click
16
- import dnnlib
17
  import numpy as np
18
  import PIL.Image
19
  import torch
20
- import legacy
21
 
22
  #----------------------------------------------------------------------------
23
 
@@ -68,7 +66,7 @@ def make_transform(translate: Tuple[float,float], angle: float):
68
  #----------------------------------------------------------------------------
69
 
70
  @click.command()
71
- @click.option('--network', 'network_pkl', help='Network pickle filename', required=True)
72
  @click.option('--seeds', type=parse_range, help='List of random seeds (e.g., \'0,1,4-6\')', required=True)
73
  @click.option('--trunc', 'truncation_psi', type=float, help='Truncation psi', default=1, show_default=True)
74
  @click.option('--class', 'class_idx', type=int, help='Class label (unconditional if not specified)')
@@ -77,7 +75,6 @@ def make_transform(translate: Tuple[float,float], angle: float):
77
  @click.option('--rotate', help='Rotation angle in degrees', type=float, default=0, show_default=True, metavar='ANGLE')
78
  @click.option('--outdir', help='Where to save the output images', type=str, required=True, metavar='DIR')
79
  def generate_images(
80
- network_pkl: str,
81
  seeds: List[int],
82
  truncation_psi: float,
83
  noise_mode: str,
@@ -103,10 +100,8 @@ def generate_images(
103
 
104
  print('Loading networks from "%s"...' % network_pkl)
105
  device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
106
- with dnnlib.util.open_url(network_pkl) as f:
107
- G = legacy.load_network_pkl(f)['G_ema'].to(device) # type: ignore
108
-
109
- os.makedirs(outdhf_ShHdFYTLiCYbxIuldloQmxMXgPvuEyUPAkir, exist_ok=True)
110
 
111
  # Labels.
112
  label = torch.zeros([1, G.c_dim], device=device)
 
11
  import os
12
  import re
13
  from typing import List, Optional, Tuple, Union
 
14
  import click
 
15
  import numpy as np
16
  import PIL.Image
17
  import torch
18
+ from networks_fastgan import MyGenerator
19
 
20
  #----------------------------------------------------------------------------
21
 
 
66
  #----------------------------------------------------------------------------
67
 
68
  @click.command()
69
+ @click.option('--network', 'network_pkl', help='Network pickle filename', required=False)
70
  @click.option('--seeds', type=parse_range, help='List of random seeds (e.g., \'0,1,4-6\')', required=True)
71
  @click.option('--trunc', 'truncation_psi', type=float, help='Truncation psi', default=1, show_default=True)
72
  @click.option('--class', 'class_idx', type=int, help='Class label (unconditional if not specified)')
 
75
  @click.option('--rotate', help='Rotation angle in degrees', type=float, default=0, show_default=True, metavar='ANGLE')
76
  @click.option('--outdir', help='Where to save the output images', type=str, required=True, metavar='DIR')
77
  def generate_images(
 
78
  seeds: List[int],
79
  truncation_psi: float,
80
  noise_mode: str,
 
100
 
101
  print('Loading networks from "%s"...' % network_pkl)
102
  device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
103
+ G = MyGenerator.from_pretrained("Cropinky/projected_gan_impressionism")
104
+ os.makedirs(outdir, exist_ok=True)
 
 
105
 
106
  # Labels.
107
  label = torch.zeros([1, G.c_dim], device=device)