INNER CODE UNIT · Python
center
gokayfem/awesome-vlm-architectures · scripts/extract_architecture_figures.py:100
center = (caption.x0 + caption.x1) / 2
if center < page_rect.width / 2:
x0, x1 = page_rect.width * 0.035, page_rect.width * 0.51
else:
x0, x1 = page_rect.width * 0.49, page_rect.width * 0.965
else:
x0, x1 = page_rect.width * 0.035, page_rect.width * 0.965
horizontal = fitz.Rect(x0, 0, x1, page_rect.height)
previous = prose_block_before(page, caption, horizontal)
top = previous.y1 + 5 if previous else max(page_rect.y0 + 32, caption.y0 - 390)
if caption.y0 - top < 88:
top = max(page_rect.y0 + 28, caption.y0 - 230)
if caption.y0 - top > 420:
top = caption.y0 - 420
return fitz.Rect(x0, top, x1, max(top + 20, caption.y0 - 3))
def trim_white(image: Image.Image, padding: int = 18) -> Image.Image: