el-el-san commited on
Commit
f50d2cc
1 Parent(s): 4df8119

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import numpy as np
3
  import PIL.Image
 
4
  import random
5
  #from diffusers import DiffusionPipeline
6
  #from diffusers import StableDiffusionXLPipeline
@@ -113,6 +114,12 @@ def nms(x, t, s):
113
  @spaces.GPU
114
  def infer(image: PIL.Image.Image,prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps)-> PIL.Image.Image:
115
 
 
 
 
 
 
 
116
  if randomize_seed:
117
  seed = random.randint(0, MAX_SEED)
118
 
 
1
  import gradio as gr
2
  import numpy as np
3
  import PIL.Image
4
+ from PIL import Image, ImageOps
5
  import random
6
  #from diffusers import DiffusionPipeline
7
  #from diffusers import StableDiffusionXLPipeline
 
114
  @spaces.GPU
115
  def infer(image: PIL.Image.Image,prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps)-> PIL.Image.Image:
116
 
117
+ width, height = image['composite'].size
118
+ ratio = np.sqrt(1024. * 1024. / (width * height))
119
+ new_width, new_height = int(width * ratio), int(height * ratio)
120
+ image = image['composite'].resize((new_width, new_height))
121
+
122
+
123
  if randomize_seed:
124
  seed = random.randint(0, MAX_SEED)
125