Update app.py
Browse files9 unmodified lines10111213141511 unmodified lines2728293031323334353637383942 unmodified lines82838485869 unmodified lines)has_cuda = th.cuda.is_available()device = th.device('cpu' if not has_cuda else 'cuda')# Create upsampler model.options_up = model_and_diffusion_defaults_upsampler()options_up['use_fp16'] = has_cuda11 unmodified linesreshaped = scaled.permute(2, 0, 3, 1).reshape([batch.shape[2], -1, 3])display(Image.fromarray(reshaped.numpy()))# Sampling parametersprompt = ""batch_size = 1guidance_scale = 3.0# Tune this parameter to control the sharpness of 256x256 images.# A value of 1.0 is sharper, but sometimes results in grainy artifacts.upsample_temp = 0.997import gradio as grdef generate_upsampled_image_from_text(prompt):# Set the prompt text42 unmodified lines# Show the outputshow_images(up_samples)demo = gr.Interface(fn =generate_upsampled_image_from_text,inputs ="text",outputs ="image")demo.launch()9 unmodified lines101112131415161718192021222324252611 unmodified lines383940414243444546474849505142 unmodified lines94959697989 unmodified lines)has_cuda = th.cuda.is_available()device = th.device('cpu' if not has_cuda else 'cuda')# Create base model.options = model_and_diffusion_defaults()options['use_fp16'] = has_cudaoptions['timestep_respacing'] = '100' # use 100 diffusion steps for fast samplingmodel, diffusion = create_model_and_diffusion(**options)model.eval()if has_cuda:model.convert_to_fp16()model.to(device)model.load_state_dict(load_checkpoint('base', device))print('total base parameters', sum(x.numel() for x in model.parameters()))# Create upsampler model.options_up = model_and_diffusion_defaults_upsampler()options_up['use_fp16'] = has_cuda11 unmodified linesreshaped = scaled.permute(2, 0, 3, 1).reshape([batch.shape[2], -1, 3])display(Image.fromarray(reshaped.numpy()))# Sampling parametersprompt = "an oil painting of a corgi"batch_size = 1guidance_scale = 3.0# Tune this parameter to control the sharpness of 256x256 images.# A value of 1.0 is sharper, but sometimes results in grainy artifacts.upsample_temp = 0.997import gradio as grdef generate_upsampled_image_from_text(prompt):# Set the prompt text42 unmodified lines# Show the outputshow_images(up_samples)demo = gr.Interface(fn =generate_upsampled_image_from_text ="text",outputs ="image")demo.launch()
app.py+15-3