Manjushri commited on
Commit
0770429
1 Parent(s): 84dfc6c

Update app.py

Browse files

Unfortunately there is no negative prompt for 4x upscaler, actually even tested it already... Two weeks ago, oh well,it would be interesting

Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -9,11 +9,11 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
9
  pipe = StableDiffusionUpscalePipeline.from_pretrained(model_id, torch_dtype=torch.float16, revision="fp16") if torch.cuda.is_available() else StableDiffusionUpscalePipeline.from_pretrained(model_id)
10
  pipe = pipe.to(device)
11
  #define interface
12
- def upscale(low_res_img, prompt, negative_prompt):
13
  low_res_img = Image.open(low_res_img).convert("RGB")
14
  low_res_img = low_res_img.resize((128, 128))
15
- upscaled_image = pipe(prompt=prompt, negative_prompt=negative_prompt, image=low_res_img, guidance_scale=1, num_inference_steps=50).images[0]
16
  upscaled_image.save("upsampled.png")
17
  return upscaled_image
18
  #launch interface
19
- gr.Interface(fn=upscale, inputs=[gr.Image(type='filepath', label='Low Resolution Image (less than 512x512, i.e. 128x128, 256x256, ect., ect..)'), gr.Textbox(label='Optional: Enter a Prompt to Slightly Guide the AI'), gr.Textbox(label='Negative Prompt: Slightly change what NOT to add')], outputs=gr.Image(type='filepath'), title='SD 2.0 4x Upscaler', description='A 4x Low Resolution Upscaler using SD 2.0. Currently it takes about 15mins an image. <br>Expects a Lower than 512x512 image. <br><br><b>Warning: Images 512x512 or Higher Resolution WILL NOT BE UPSCALED and may result in Quality Loss!', article = "Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(max_threads=True, debug=True)
 
9
  pipe = StableDiffusionUpscalePipeline.from_pretrained(model_id, torch_dtype=torch.float16, revision="fp16") if torch.cuda.is_available() else StableDiffusionUpscalePipeline.from_pretrained(model_id)
10
  pipe = pipe.to(device)
11
  #define interface
12
+ def upscale(low_res_img, prompt):
13
  low_res_img = Image.open(low_res_img).convert("RGB")
14
  low_res_img = low_res_img.resize((128, 128))
15
+ upscaled_image = pipe(prompt=prompt, image=low_res_img, guidance_scale=1, num_inference_steps=50).images[0]
16
  upscaled_image.save("upsampled.png")
17
  return upscaled_image
18
  #launch interface
19
+ gr.Interface(fn=upscale, inputs=[gr.Image(type='filepath', label='Low Resolution Image (less than 512x512, i.e. 128x128, 256x256, ect., ect..)'), gr.Textbox(label='Optional: Enter a Prompt to Slightly Guide the AI')], outputs=gr.Image(type='filepath'), title='SD 2.0 4x Upscaler', description='A 4x Low Resolution Upscaler using SD 2.0. Currently it takes about 15mins an image. <br>Expects a Lower than 512x512 image. <br><br><b>Warning: Images 512x512 or Higher Resolution WILL NOT BE UPSCALED and may result in Quality Loss!', article = "Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(max_threads=True, debug=True)