michaelapplydesign commited on
Commit
b8e6b50
·
1 Parent(s): 131bf04
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -70,19 +70,25 @@ def segmentation(img):
70
 
71
 
72
  def upscale(image, prompt):
73
- print("upscale")
74
 
75
- image = image.thumbnail((512, 512))
 
76
 
77
- model_id = "stabilityai/stable-diffusion-x4-upscaler"
78
- pipeline = StableDiffusionUpscalePipeline.from_pretrained(model_id, torch_dtype=torch.float16)
79
  pipeline = pipeline.to("cuda")
80
 
81
 
82
  #pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-x4-upscaler")
83
  # pipeline = StableDiffusionLatentUpscalePipeline.from_pretrained("stabilityai/sd-x2-latent-upscaler", torch_dtype=torch.float16).to('cuda')
84
-
85
- upscaled_image = pipeline(prompt=prompt, image=image).images[0]
 
 
 
 
 
 
86
  return upscaled_image
87
 
88
  with gr.Blocks() as app:
 
70
 
71
 
72
  def upscale(image, prompt):
73
+ print("upscale",image,prompt)
74
 
75
+ image.thumbnail((512, 512))
76
+ print("resize",image)
77
 
78
+ pipeline = StableDiffusionUpscalePipeline.from_pretrained("stabilityai/stable-diffusion-x4-upscaler", torch_dtype=torch.float16)
 
79
  pipeline = pipeline.to("cuda")
80
 
81
 
82
  #pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-x4-upscaler")
83
  # pipeline = StableDiffusionLatentUpscalePipeline.from_pretrained("stabilityai/sd-x2-latent-upscaler", torch_dtype=torch.float16).to('cuda')
84
+ ret = pipeline(prompt=prompt,
85
+ image=image,
86
+ num_inference_steps=20,
87
+ guidance_scale=0)
88
+ print("ret",ret)
89
+ upscaled_image = ret.images[0]
90
+ print("up",upscaled_image)
91
+
92
  return upscaled_image
93
 
94
  with gr.Blocks() as app: