MCPcopy Create free account
hub / github.com/OpenBMB/AgentCPM-GUI / get_refine_size

Function get_refine_size

sft/dataset.py:514–535  ·  view source on GitHub ↗
(
    original_size, grid, scale_resolution, patch_size, allow_upscale=False
)

Source from the content-addressed store, hash-verified

512
513
514def get_refine_size(
515 original_size, grid, scale_resolution, patch_size, allow_upscale=False
516):
517 width, height = original_size
518 grid_x, grid_y = grid
519
520 refine_width = ensure_divide(width, grid_x)
521 refine_height = ensure_divide(height, grid_y)
522
523 grid_width = refine_width / grid_x
524 grid_height = refine_height / grid_y
525
526 best_grid_size = find_best_resize(
527 (grid_width, grid_height),
528 scale_resolution,
529 patch_size,
530 allow_upscale=allow_upscale,
531 )
532
533 refine_size = (best_grid_size[0] * grid_x, best_grid_size[1] * grid_y)
534
535 return refine_size
536
537
538def split_to_patches(image, grid):

Callers 1

slice_imageFunction · 0.85

Calls 2

ensure_divideFunction · 0.85
find_best_resizeFunction · 0.85

Tested by

no test coverage detected