linoyts HF staff commited on
Commit
cabaad6
·
verified ·
1 Parent(s): 9b95948

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -124,7 +124,7 @@ def end_session(req: gr.Request):
124
 
125
 
126
  def preprocess_image(image: Image.Image,
127
- prompt: str,
128
  negative_prompt: str = "",
129
  style_name: str = "",
130
  num_steps: int = 25,
@@ -139,25 +139,25 @@ def preprocess_image(image: Image.Image,
139
  Returns:
140
  Image.Image: The preprocessed image.
141
  """
142
- if prompt is not None:
143
 
144
- width, height = image['composite'].size
145
- ratio = np.sqrt(1024. * 1024. / (width * height))
146
- new_width, new_height = int(width * ratio), int(height * ratio)
147
- image = image['composite'].resize((new_width, new_height))
148
 
149
- prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
150
-
151
- image = pipe_control(
152
- prompt=prompt,
153
- negative_prompt=negative_prompt,
154
- image=image,
155
- num_inference_steps=num_steps,
156
- controlnet_conditioning_scale=controlnet_conditioning_scale,
157
- guidance_scale=guidance_scale,
158
- width=new_width,
159
- height=new_height).images[0]
160
- print(type(image))
 
161
 
162
  processed_image = pipeline.preprocess_image(image)
163
  return processed_image
 
124
 
125
 
126
  def preprocess_image(image: Image.Image,
127
+ prompt: str = "",
128
  negative_prompt: str = "",
129
  style_name: str = "",
130
  num_steps: int = 25,
 
139
  Returns:
140
  Image.Image: The preprocessed image.
141
  """
 
142
 
143
+ width, height = image['composite'].size
144
+ ratio = np.sqrt(1024. * 1024. / (width * height))
145
+ new_width, new_height = int(width * ratio), int(height * ratio)
146
+ image = image['composite'].resize((new_width, new_height))
147
 
148
+ prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
149
+
150
+ print(prompt, negative_prompt, style_name, num_steps, guidance_scale, controlnet_conditioning_scale)
151
+ image = pipe_control(
152
+ prompt=prompt,
153
+ negative_prompt=negative_prompt,
154
+ image=image,
155
+ num_inference_steps=num_steps,
156
+ controlnet_conditioning_scale=controlnet_conditioning_scale,
157
+ guidance_scale=guidance_scale,
158
+ width=new_width,
159
+ height=new_height).images[0]
160
+
161
 
162
  processed_image = pipeline.preprocess_image(image)
163
  return processed_image