apolinario commited on
Commit
7c17938
1 Parent(s): 56049a8

Downsize to fit

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -135,7 +135,7 @@ clip_model = CLIP()
135
 
136
  #@markdown #**Model selection** 🎭
137
 
138
- Models = ["imagenet256"]#, "Imagenet512", "Imagenet1024", "Pokemon", "FFHQ"]
139
 
140
  #@markdown ---
141
 
@@ -143,8 +143,8 @@ network_url = {
143
  "imagenet256":"https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/imagenet256.pkl",
144
  #"Imagenet512": "https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/imagenet512.pkl",
145
  #"Imagenet1024": "https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/imagenet1024.pkl",
146
- #"Pokemon": "https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/pokemon256.pkl",
147
- #"FFHQ": "https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/ffhq256.pkl"
148
  }
149
 
150
  for Model in Models:
@@ -172,10 +172,10 @@ def run(prompt,steps,model):
172
  global G, w_stds, w_all_classes_avg, previousModel
173
  if(model == 'imagenet256' and previousModel != 'imagenet256'):
174
  G, w_stds, w_all_classes_avg = load_current_model('imagenet256.pkl')
175
- if(model == 'imagenet512' and previousModel != 'imagenet512'):
176
- G, w_stds, w_all_classes_avg = load_current_model('imagenet512.pkl')
177
- elif(model=='imagenet1024' and previousModel != 'imagenet1024'):
178
- G, w_stds, w_all_classes_avg = load_current_model('imagenet1024.pkl')
179
  elif(model=='pokemon256' and previousModel != 'pokemon256'):
180
  G, w_stds, w_all_classes_avg = load_current_model('pokemon256.pkl')
181
  elif(model=='ffhq256' and previousModel != 'ffhq256'):
@@ -204,7 +204,7 @@ def run(prompt,steps,model):
204
  )
205
 
206
  initial_batch = 2 # actually that will be multiplied by initial_image_steps
207
- initial_image_steps = 16
208
 
209
  def get_image(timestring):
210
  os.makedirs(f"samples/{timestring}", exist_ok=True)
@@ -267,12 +267,12 @@ def run(prompt,steps,model):
267
 
268
  image = gr.outputs.Image(type="pil", label="Your imge")
269
  video = gr.outputs.Video(type="mp4", label="Your video")
270
- css = ".output-image{height: 528px !important},.output-video{height: 528px !important}"
271
  iface = gr.Interface(fn=run, inputs=[
272
  gr.inputs.Textbox(label="Prompt",default="chalk pastel drawing of a dog wearing a funny hat"),
273
  gr.inputs.Slider(label="Steps - more steps can increase quality but will take longer to generate",default=300,maximum=500,minimum=10,step=1),
274
  #gr.inputs.Radio(label="Aspect Ratio", choices=["Square", "Horizontal", "Vertical"],default="Horizontal"),
275
- gr.inputs.Dropdown(label="Model", choices=["imagenet256","imagenet512","imagenet1024","Pokemon256", "ffhq256"], default="imagenet256")
276
  #gr.inputs.Radio(label="Height", choices=[32,64,128,256,512],default=256),
277
  #gr.inputs.Slider(label="Images - How many images you wish to generate", default=2, step=1, minimum=1, maximum=4),
278
  #gr.inputs.Slider(label="Diversity scale - How different from one another you wish the images to be",default=5.0, minimum=1.0, maximum=15.0),
 
135
 
136
  #@markdown #**Model selection** 🎭
137
 
138
+ Models = ["imagenet256", "Imagenet512", "Pokemon", "FFHQ"]
139
 
140
  #@markdown ---
141
 
 
143
  "imagenet256":"https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/imagenet256.pkl",
144
  #"Imagenet512": "https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/imagenet512.pkl",
145
  #"Imagenet1024": "https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/imagenet1024.pkl",
146
+ "Pokemon": "https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/pokemon256.pkl",
147
+ "FFHQ": "https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/ffhq256.pkl"
148
  }
149
 
150
  for Model in Models:
 
172
  global G, w_stds, w_all_classes_avg, previousModel
173
  if(model == 'imagenet256' and previousModel != 'imagenet256'):
174
  G, w_stds, w_all_classes_avg = load_current_model('imagenet256.pkl')
175
+ #if(model == 'imagenet512' and previousModel != 'imagenet512'):
176
+ # G, w_stds, w_all_classes_avg = load_current_model('imagenet512.pkl')
177
+ #elif(model=='imagenet1024' and previousModel != 'imagenet1024'):
178
+ # G, w_stds, w_all_classes_avg = load_current_model('imagenet1024.pkl')
179
  elif(model=='pokemon256' and previousModel != 'pokemon256'):
180
  G, w_stds, w_all_classes_avg = load_current_model('pokemon256.pkl')
181
  elif(model=='ffhq256' and previousModel != 'ffhq256'):
 
204
  )
205
 
206
  initial_batch = 2 # actually that will be multiplied by initial_image_steps
207
+ initial_image_steps = 8
208
 
209
  def get_image(timestring):
210
  os.makedirs(f"samples/{timestring}", exist_ok=True)
 
267
 
268
  image = gr.outputs.Image(type="pil", label="Your imge")
269
  video = gr.outputs.Video(type="mp4", label="Your video")
270
+ css = ".output-image{height: 528px !important} .output-video{height: 528px !important}"
271
  iface = gr.Interface(fn=run, inputs=[
272
  gr.inputs.Textbox(label="Prompt",default="chalk pastel drawing of a dog wearing a funny hat"),
273
  gr.inputs.Slider(label="Steps - more steps can increase quality but will take longer to generate",default=300,maximum=500,minimum=10,step=1),
274
  #gr.inputs.Radio(label="Aspect Ratio", choices=["Square", "Horizontal", "Vertical"],default="Horizontal"),
275
+ gr.inputs.Dropdown(label="Model", choices=["imagenet256","Pokemon256", "ffhq256"], default="imagenet256")
276
  #gr.inputs.Radio(label="Height", choices=[32,64,128,256,512],default=256),
277
  #gr.inputs.Slider(label="Images - How many images you wish to generate", default=2, step=1, minimum=1, maximum=4),
278
  #gr.inputs.Slider(label="Diversity scale - How different from one another you wish the images to be",default=5.0, minimum=1.0, maximum=15.0),