Ahsen Khaliq commited on
Commit
641acff
1 Parent(s): 8784fa4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -78,7 +78,7 @@ def tv_loss(input):
78
  def range_loss(input):
79
  return (input - input.clamp(-1, 1)).pow(2).mean([1, 2, 3])
80
 
81
- def inference(text, init_image, skip_timesteps, clip_guidance_scale, tv_scale, range_scale, init_scale, seed, image_prompts,timestep_respacing):
82
  # Model settings
83
  model_config = model_and_diffusion_defaults()
84
  model_config.update({
@@ -126,7 +126,7 @@ def inference(text, init_image, skip_timesteps, clip_guidance_scale, tv_scale, r
126
  clip_guidance_scale = clip_guidance_scale # Controls how much the image should look like the prompt.
127
  tv_scale = tv_scale # Controls the smoothness of the final output.
128
  range_scale = range_scale # Controls how far out of range RGB values are allowed to be.
129
- cutn = 16
130
  n_batches = 1
131
  if init_image:
132
  init_image = init_image.name
@@ -221,6 +221,6 @@ def inference(text, init_image, skip_timesteps, clip_guidance_scale, tv_scale, r
221
  title = "CLIP Guided Diffusion HQ"
222
  description = "Gradio demo for CLIP Guided Diffusion. To use it, simply add your text, or click one of the examples to load them. Read more at the links below."
223
  article = "<p style='text-align: center'> By Katherine Crowson (https://github.com/crowsonkb, https://twitter.com/RiversHaveWings). It uses OpenAI's 256x256 unconditional ImageNet diffusion model (https://github.com/openai/guided-diffusion) together with CLIP (https://github.com/openai/CLIP) to connect text prompts with images. | <a href='https://colab.research.google.com/drive/12a_Wrfi2_gwwAuN3VvMTwVMz9TfqctNj' target='_blank'>Colab</a></p>"
224
- iface = gr.Interface(inference, inputs=["text",gr.inputs.Image(type="file", label='initial image (optional)', optional=True),gr.inputs.Slider(minimum=0, maximum=45, step=1, default=0, label="skip_timesteps"), gr.inputs.Slider(minimum=0, maximum=3000, step=1, default=700, label="clip guidance scale (Controls how much the image should look like the prompt)"), gr.inputs.Slider(minimum=0, maximum=1000, step=1, default=150, label="tv_scale (Controls the smoothness of the final output)"), gr.inputs.Slider(minimum=0, maximum=1000, step=1, default=50, label="range_scale (Controls how far out of range RGB values are allowed to be)"), gr.inputs.Slider(minimum=0, maximum=1000, step=1, default=0, label="init_scale (This enhances the effect of the init image)"), gr.inputs.Number(default=0, label="Seed"), gr.inputs.Image(type="file", label='image prompt (optional)', optional=True), gr.inputs.Slider(minimum=50, maximum=500, step=1, default=90, label="timestep respacing")], outputs=["image","video"], title=title, description=description, article=article, examples=[["coral reef city by artistation artists", None, 0, 1000, 150, 50, 0, 0, None, 90]],
225
  enable_queue=True)
226
  iface.launch()
 
78
  def range_loss(input):
79
  return (input - input.clamp(-1, 1)).pow(2).mean([1, 2, 3])
80
 
81
+ def inference(text, init_image, skip_timesteps, clip_guidance_scale, tv_scale, range_scale, init_scale, seed, image_prompts,timestep_respacing, cutn):
82
  # Model settings
83
  model_config = model_and_diffusion_defaults()
84
  model_config.update({
 
126
  clip_guidance_scale = clip_guidance_scale # Controls how much the image should look like the prompt.
127
  tv_scale = tv_scale # Controls the smoothness of the final output.
128
  range_scale = range_scale # Controls how far out of range RGB values are allowed to be.
129
+ cutn = cutn
130
  n_batches = 1
131
  if init_image:
132
  init_image = init_image.name
 
221
  title = "CLIP Guided Diffusion HQ"
222
  description = "Gradio demo for CLIP Guided Diffusion. To use it, simply add your text, or click one of the examples to load them. Read more at the links below."
223
  article = "<p style='text-align: center'> By Katherine Crowson (https://github.com/crowsonkb, https://twitter.com/RiversHaveWings). It uses OpenAI's 256x256 unconditional ImageNet diffusion model (https://github.com/openai/guided-diffusion) together with CLIP (https://github.com/openai/CLIP) to connect text prompts with images. | <a href='https://colab.research.google.com/drive/12a_Wrfi2_gwwAuN3VvMTwVMz9TfqctNj' target='_blank'>Colab</a></p>"
224
+ iface = gr.Interface(inference, inputs=["text",gr.inputs.Image(type="file", label='initial image (optional)', optional=True),gr.inputs.Slider(minimum=0, maximum=45, step=1, default=10, label="skip_timesteps"), gr.inputs.Slider(minimum=0, maximum=3000, step=1, default=750, label="clip guidance scale (Controls how much the image should look like the prompt)"), gr.inputs.Slider(minimum=0, maximum=1000, step=1, default=0, label="tv_scale (Controls the smoothness of the final output)"), gr.inputs.Slider(minimum=0, maximum=1000, step=1, default=0, label="range_scale (Controls how far out of range RGB values are allowed to be)"), gr.inputs.Slider(minimum=0, maximum=1000, step=1, default=0, label="init_scale (This enhances the effect of the init image)"), gr.inputs.Number(default=0, label="Seed"), gr.inputs.Image(type="file", label='image prompt (optional)', optional=True), gr.inputs.Slider(minimum=50, maximum=500, step=1, default=50, label="timestep respacing"),gr.inputs.Slider(minimum=1, maximum=64, step=1, default=64, label="cutn")], outputs=["image","video"], title=title, description=description, article=article, examples=[["coral reef city by artistation artists", None, 0, 1000, 150, 50, 0, 0, None, 90]],
225
  enable_queue=True)
226
  iface.launch()