feat✨: 增加图像尺寸调整逻辑以支持小于28的宽高
This commit is contained in:
parent
7cf28e9851
commit
8d6e5d5416
@ -66,6 +66,13 @@ class OCRVQADataset(Dataset):
|
|||||||
new_width = int(width * ratio)
|
new_width = int(width * ratio)
|
||||||
new_height = int(height * ratio)
|
new_height = int(height * ratio)
|
||||||
image = image.resize((new_width, new_height), Image.Resampling.BILINEAR)
|
image = image.resize((new_width, new_height), Image.Resampling.BILINEAR)
|
||||||
|
|
||||||
|
if width < 28 or height < 28:
|
||||||
|
min_size = min(width, height)
|
||||||
|
ratio = 28 / min_size + 1
|
||||||
|
new_width = int(width * ratio)
|
||||||
|
new_height = int(height * ratio)
|
||||||
|
image = image.resize((new_width, new_height), Image.Resampling.BILINEAR)
|
||||||
|
|
||||||
question = sample["question"]
|
question = sample["question"]
|
||||||
answer = sample["answer"]
|
answer = sample["answer"]
|
||||||
|
Loading…
Reference in New Issue
Block a user