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

Function load_resized_image

rft/trainer/utils/dataset.py:24–38  ·  view source on GitHub ↗
(img_file:str|io.BytesIO, max_line_res: Optional[int] = None)

Source from the content-addressed store, hash-verified

22import zmq
23
24def load_resized_image(img_file:str|io.BytesIO, max_line_res: Optional[int] = None):
25 origin_img = Image.open(img_file).convert("RGB")
26 w,h = origin_img.size
27 if max_line_res is not None:
28 if h > max_line_res:
29 w = int(w * max_line_res / h)
30 h = max_line_res
31 if w > max_line_res:
32 h = int(h * max_line_res / w)
33 w = max_line_res
34 img = origin_img.resize((w,h),resample=Image.Resampling.LANCZOS)
35 else:
36 img = origin_img
37
38 return img,origin_img
39
40class GUIRFTDataset(Dataset):
41 def __init__(self, jsonl_file_path: str, max_line_res: int|None = None, *args, **kwargs):

Callers 1

__getitem__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected