Spaces:
Sleeping
Sleeping
lichorosario
commited on
Commit
·
a92de99
1
Parent(s):
4274e8e
feat: Refactorizar función de refinamiento de imágenes en app.py
Browse files
app.py
CHANGED
@@ -134,29 +134,11 @@ def save_image(image):
|
|
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
|
158 |
|
159 |
-
image = image[1]
|
160 |
try:
|
161 |
client_tile_upscaler = Client(tile_upscaler_url)
|
162 |
print(f"Loaded custom model from {tile_upscaler_url}")
|
@@ -201,6 +183,24 @@ def upscale_image(image, resolution, num_inference_steps, strength, hdr, guidanc
|
|
201 |
return [image, result]
|
202 |
|
203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
css="""
|
205 |
"""
|
206 |
|
|
|
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
|
140 |
|
141 |
+
# image = image[1]
|
142 |
try:
|
143 |
client_tile_upscaler = Client(tile_upscaler_url)
|
144 |
print(f"Loaded custom model from {tile_upscaler_url}")
|
|
|
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 |
|