Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,11 @@

# Copied from diffusers.pipelines.kandinsky2_2.pipeline_kandinsky2_2.downscale_height_and_width
def downscale_height_and_width(height, width, scale_factor=8):
new_height = height // scale_factor**2
if height % scale_factor**2 != 0:
new_height += 1
new_width = width // scale_factor**2
if width % scale_factor**2 != 0:
new_width += 1
return new_height * scale_factor, new_width * scale_factor
# Optimize by avoiding repeated exponentiation and using integer division with ceil in a single step
sf2 = scale_factor * scale_factor
new_height = -(-height // sf2) * scale_factor # Equivalent to math.ceil(height/sf2)*scale_factor
new_width = -(-width // sf2) * scale_factor
return new_height, new_width


class KandinskyV22ControlnetPipeline(DiffusionPipeline):
Expand Down