Spaces:
Sleeping
Sleeping
lichorosario
commited on
Commit
•
69f2da4
1
Parent(s):
7e809df
feat: Refactorizar función de refinamiento de imágenes en app.py
Browse files
app.py
CHANGED
@@ -96,7 +96,7 @@ def infer(selected_index, prompt, style_prompt, inf_steps, guidance_scale, width
|
|
96 |
used_seed = result[1] # Esto puede necesitar ser ajustado basado en la estructura real de result
|
97 |
used_prompt = prompt # El prompt usado es simplemente el prompt procesado
|
98 |
|
99 |
-
return generated_image_path, used_seed, used_prompt
|
100 |
|
101 |
except Exception as e:
|
102 |
gr.Warning("Error: " + str(e))
|
@@ -136,7 +136,7 @@ def save_image(image):
|
|
136 |
def upscale_image(image, resolution, num_inference_steps, strength, hdr, guidance_scale, controlnet_strength, scheduler_name, reduce_factor):
|
137 |
global client_tile_upscaler
|
138 |
|
139 |
-
|
140 |
try:
|
141 |
client_tile_upscaler = Client(tile_upscaler_url)
|
142 |
print(f"Loaded custom model from {tile_upscaler_url}")
|
@@ -175,7 +175,7 @@ def refine_image(apply_refiner, image, model ,prompt, negative_prompt, num_infer
|
|
175 |
|
176 |
client = InferenceClient()
|
177 |
refined_image = client.image_to_image(
|
178 |
-
image,
|
179 |
prompt=prompt,
|
180 |
negative_prompt=negative_prompt,
|
181 |
num_inference_steps=num_inference_steps,
|
@@ -184,7 +184,7 @@ def refine_image(apply_refiner, image, model ,prompt, negative_prompt, num_infer
|
|
184 |
model=model,
|
185 |
strength=strength
|
186 |
)
|
187 |
-
return refined_image
|
188 |
|
189 |
|
190 |
css="""
|
@@ -337,7 +337,7 @@ with gr.Blocks(css=css) as demo:
|
|
337 |
|
338 |
with gr.Row():
|
339 |
with gr.Column():
|
340 |
-
generated_image = gr.
|
341 |
enhace_button = gr.Button("Enhance Image")
|
342 |
|
343 |
with gr.Column():
|
|
|
96 |
used_seed = result[1] # Esto puede necesitar ser ajustado basado en la estructura real de result
|
97 |
used_prompt = prompt # El prompt usado es simplemente el prompt procesado
|
98 |
|
99 |
+
return [generated_image_path, generated_image_path], used_seed, used_prompt
|
100 |
|
101 |
except Exception as e:
|
102 |
gr.Warning("Error: " + str(e))
|
|
|
136 |
def upscale_image(image, resolution, num_inference_steps, strength, hdr, guidance_scale, controlnet_strength, scheduler_name, reduce_factor):
|
137 |
global client_tile_upscaler
|
138 |
|
139 |
+
image = image[1]
|
140 |
try:
|
141 |
client_tile_upscaler = Client(tile_upscaler_url)
|
142 |
print(f"Loaded custom model from {tile_upscaler_url}")
|
|
|
175 |
|
176 |
client = InferenceClient()
|
177 |
refined_image = client.image_to_image(
|
178 |
+
image[0],
|
179 |
prompt=prompt,
|
180 |
negative_prompt=negative_prompt,
|
181 |
num_inference_steps=num_inference_steps,
|
|
|
184 |
model=model,
|
185 |
strength=strength
|
186 |
)
|
187 |
+
return [image[0], refined_image]
|
188 |
|
189 |
|
190 |
css="""
|
|
|
337 |
|
338 |
with gr.Row():
|
339 |
with gr.Column():
|
340 |
+
generated_image = gr.ImageSlider(label="Image / Refined Image", type="filepath")
|
341 |
enhace_button = gr.Button("Enhance Image")
|
342 |
|
343 |
with gr.Column():
|