lichorosario commited on
Commit
4274e8e
1 Parent(s): 88fcd4f

feat: Refactorizar función de refinamiento de imágenes en app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -134,6 +134,24 @@ def save_image(image):
134
  image.save(unique_filename)
135
  return unique_filename
136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
  def upscale_image(image, resolution, num_inference_steps, strength, hdr, guidance_scale, controlnet_strength, scheduler_name, reduce_factor):
139
  global client_tile_upscaler
@@ -166,7 +184,7 @@ def upscale_image(image, resolution, num_inference_steps, strength, hdr, guidanc
166
  print(f"Reduce Factor: {reduce_factor}")
167
 
168
  job = client_tile_upscaler.submit(
169
- param_0=image,
170
  param_1=resolution,
171
  param_2=num_inference_steps,
172
  param_3=strength,
@@ -183,24 +201,6 @@ def upscale_image(image, resolution, num_inference_steps, strength, hdr, guidanc
183
  return [image, result]
184
 
185
 
186
- def refine_image(apply_refiner, image, model ,prompt, negative_prompt, num_inference_steps, guidance_scale, seed, strength):
187
- if (not apply_refiner):
188
- return image
189
-
190
- client = InferenceClient()
191
- refined_image = client.image_to_image(
192
- handle_file(image),
193
- prompt=prompt,
194
- negative_prompt=negative_prompt,
195
- num_inference_steps=num_inference_steps,
196
- guidance_scale=guidance_scale,
197
- seed=seed,
198
- model=model,
199
- strength=strength
200
- )
201
- return refined_image
202
-
203
-
204
  css="""
205
  """
206
 
 
134
  image.save(unique_filename)
135
  return unique_filename
136
 
137
+ def refine_image(apply_refiner, image, model ,prompt, negative_prompt, num_inference_steps, guidance_scale, seed, strength):
138
+ if (not apply_refiner):
139
+ return image
140
+
141
+ client = InferenceClient()
142
+ refined_image = client.image_to_image(
143
+ handle_file(image),
144
+ prompt=prompt,
145
+ negative_prompt=negative_prompt,
146
+ num_inference_steps=num_inference_steps,
147
+ guidance_scale=guidance_scale,
148
+ seed=seed,
149
+ model=model,
150
+ strength=strength
151
+ )
152
+ return refined_image
153
+
154
+
155
 
156
  def upscale_image(image, resolution, num_inference_steps, strength, hdr, guidance_scale, controlnet_strength, scheduler_name, reduce_factor):
157
  global client_tile_upscaler
 
184
  print(f"Reduce Factor: {reduce_factor}")
185
 
186
  job = client_tile_upscaler.submit(
187
+ param_0=handle_file(image),
188
  param_1=resolution,
189
  param_2=num_inference_steps,
190
  param_3=strength,
 
201
  return [image, result]
202
 
203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  css="""
205
  """
206