Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
9f1ae40
1
Parent(s):
3e76623
Refactored resize image
Browse files
app.py
CHANGED
@@ -430,6 +430,11 @@ class AdjustLevels:
|
|
430 |
|
431 |
return im
|
432 |
|
|
|
|
|
|
|
|
|
|
|
433 |
def encode_image(image):
|
434 |
buffer = BytesIO()
|
435 |
image.save(buffer, format="PNG")
|
@@ -458,20 +463,13 @@ def generate_ai_bg(input_img, prompt):
|
|
458 |
|
459 |
return ic_light_img
|
460 |
|
461 |
-
def blend_details(input_image, relit_image, masked_image):
|
462 |
-
# input_image = load_image(input_image_path)
|
463 |
-
# relit_image = load_image(relit_image_path)
|
464 |
-
# masked_image = load_image(masked_image_path)
|
465 |
|
466 |
-
|
467 |
-
input_image = input_image.resize((int(input_image.width * scaling_factor),
|
468 |
-
int(input_image.height * scaling_factor)))
|
469 |
|
470 |
-
relit_image =
|
471 |
-
int(relit_image.height * scaling_factor)))
|
472 |
|
473 |
-
masked_image =
|
474 |
-
int(masked_image.height * scaling_factor)))
|
475 |
|
476 |
masked_image_rgb = split_image_with_alpha(masked_image)
|
477 |
masked_image_blurred = gaussian_blur(masked_image_rgb, radius=10)
|
@@ -549,10 +547,6 @@ def create_ui():
|
|
549 |
run_button = gr.Button(value='Run')
|
550 |
|
551 |
with gr.Column():
|
552 |
-
# gallery = gr.Gallery(
|
553 |
-
# label="Generated images", show_label=False, elem_id="gallery"
|
554 |
-
# )
|
555 |
-
# masked_image = gr.Image(label="Generated Image")
|
556 |
output_image = gr.Image(label="Generated Image")
|
557 |
|
558 |
# Run button
|
|
|
430 |
|
431 |
return im
|
432 |
|
433 |
+
def resize_image(image, scaling_factor=1):
|
434 |
+
image = image.resize((int(image.width * scaling_factor),
|
435 |
+
int(image.height * scaling_factor)))
|
436 |
+
return image
|
437 |
+
|
438 |
def encode_image(image):
|
439 |
buffer = BytesIO()
|
440 |
image.save(buffer, format="PNG")
|
|
|
463 |
|
464 |
return ic_light_img
|
465 |
|
466 |
+
def blend_details(input_image, relit_image, masked_image, scaling_factor=1):
|
|
|
|
|
|
|
467 |
|
468 |
+
input_image = resize_image(input_image)
|
|
|
|
|
469 |
|
470 |
+
relit_image = resize_image(relit_image)
|
|
|
471 |
|
472 |
+
masked_image = resize_image(masked_image)
|
|
|
473 |
|
474 |
masked_image_rgb = split_image_with_alpha(masked_image)
|
475 |
masked_image_blurred = gaussian_blur(masked_image_rgb, radius=10)
|
|
|
547 |
run_button = gr.Button(value='Run')
|
548 |
|
549 |
with gr.Column():
|
|
|
|
|
|
|
|
|
550 |
output_image = gr.Image(label="Generated Image")
|
551 |
|
552 |
# Run button
|