Update app.py
Browse files
app.py
CHANGED
@@ -106,7 +106,7 @@ def inference(text, init_image, skip_timesteps, clip_guidance_scale, tv_scale, r
|
|
106 |
if 'qkv' in name or 'norm' in name or 'proj' in name:
|
107 |
param.requires_grad_()
|
108 |
if model_config['use_fp16']:
|
109 |
-
model.
|
110 |
clip_model = clip.load('ViT-B/16', jit=False)[0].eval().requires_grad_(False).to(device)
|
111 |
clip_size = clip_model.visual.input_resolution
|
112 |
normalize = transforms.Normalize(mean=[0.48145466, 0.4578275, 0.40821073],
|
@@ -218,6 +218,6 @@ def inference(text, init_image, skip_timesteps, clip_guidance_scale, tv_scale, r
|
|
218 |
|
219 |
title = "CLIP Guided Diffusion Model"
|
220 |
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."
|
221 |
-
|
222 |
-
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=600, 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=32, label="cutn")], outputs=["image","video"], title=title, description=description, examples=[["little girl with cat on bed", "feifei.jpg", 0, 1000, 150, 50, 0, 0, "feifei.jpg", 90, 32]])
|
223 |
iface.launch()
|
|
|
106 |
if 'qkv' in name or 'norm' in name or 'proj' in name:
|
107 |
param.requires_grad_()
|
108 |
if model_config['use_fp16']:
|
109 |
+
model.convert_to_fp32()
|
110 |
clip_model = clip.load('ViT-B/16', jit=False)[0].eval().requires_grad_(False).to(device)
|
111 |
clip_size = clip_model.visual.input_resolution
|
112 |
normalize = transforms.Normalize(mean=[0.48145466, 0.4578275, 0.40821073],
|
|
|
218 |
|
219 |
title = "CLIP Guided Diffusion Model"
|
220 |
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."
|
221 |
+
article = "<p style='text-align: center'> By YuanFu Yang (https://github.com/Yfyangd/diffusion). 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. </p>"
|
222 |
+
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=600, 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=32, label="cutn")], outputs=["image","video"], title=title, article=article, description=description, examples=[["little girl with cat on bed", "feifei.jpg", 0, 1000, 150, 50, 0, 0, "feifei.jpg", 90, 32]])
|
223 |
iface.launch()
|