Spaces:
Runtime error
Runtime error
try new `resize_image_dimensions` and seed 42
Browse files
app.py
CHANGED
|
@@ -30,6 +30,11 @@ def resize_image_dimensions(
|
|
| 30 |
) -> Tuple[int, int]:
|
| 31 |
width, height = original_resolution_wh
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
if width > height:
|
| 34 |
scaling_factor = maximum_dimension / width
|
| 35 |
else:
|
|
@@ -38,11 +43,8 @@ def resize_image_dimensions(
|
|
| 38 |
new_width = int(width * scaling_factor)
|
| 39 |
new_height = int(height * scaling_factor)
|
| 40 |
|
| 41 |
-
new_width = new_width - (new_width %
|
| 42 |
-
new_height = new_height - (new_height %
|
| 43 |
-
|
| 44 |
-
new_width = min(maximum_dimension, new_width)
|
| 45 |
-
new_height = min(maximum_dimension, new_height)
|
| 46 |
|
| 47 |
return new_width, new_height
|
| 48 |
|
|
@@ -122,11 +124,11 @@ with gr.Blocks() as demo:
|
|
| 122 |
minimum=0,
|
| 123 |
maximum=MAX_SEED,
|
| 124 |
step=1,
|
| 125 |
-
value=
|
| 126 |
)
|
| 127 |
|
| 128 |
randomize_seed_checkbox_component = gr.Checkbox(
|
| 129 |
-
label="Randomize seed", value=
|
| 130 |
|
| 131 |
with gr.Row():
|
| 132 |
strength_slider_component = gr.Slider(
|
|
|
|
| 30 |
) -> Tuple[int, int]:
|
| 31 |
width, height = original_resolution_wh
|
| 32 |
|
| 33 |
+
if width <= maximum_dimension and height <= maximum_dimension:
|
| 34 |
+
width = width - (width % 8)
|
| 35 |
+
height = height - (height % 8)
|
| 36 |
+
return width, height
|
| 37 |
+
|
| 38 |
if width > height:
|
| 39 |
scaling_factor = maximum_dimension / width
|
| 40 |
else:
|
|
|
|
| 43 |
new_width = int(width * scaling_factor)
|
| 44 |
new_height = int(height * scaling_factor)
|
| 45 |
|
| 46 |
+
new_width = new_width - (new_width % 8)
|
| 47 |
+
new_height = new_height - (new_height % 8)
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
return new_width, new_height
|
| 50 |
|
|
|
|
| 124 |
minimum=0,
|
| 125 |
maximum=MAX_SEED,
|
| 126 |
step=1,
|
| 127 |
+
value=42,
|
| 128 |
)
|
| 129 |
|
| 130 |
randomize_seed_checkbox_component = gr.Checkbox(
|
| 131 |
+
label="Randomize seed", value=False)
|
| 132 |
|
| 133 |
with gr.Row():
|
| 134 |
strength_slider_component = gr.Slider(
|