InternVL icon indicating copy to clipboard operation
InternVL copied to clipboard

InternViT−6B−448px−V1.5动态分辨率如何支持

Open hgdhrt opened this issue 1 year ago • 1 comments

请问一下,我按照InternViT−6B−448px−V1.5的示例代码,经过图像前处理,发现一个长宽比不为1的图片仍然经过了centercrop,请问如何支持动态分辨率?

hgdhrt avatar May 20 '24 07:05 hgdhrt

补充示例代码

import torch
from PIL import Image
from transformers import AutoModel, CLIPImageProcessor

model = AutoModel.from_pretrained(
    'OpenGVLab/InternViT-6B-448px-V1-5',
    torch_dtype=torch.bfloat16,
    low_cpu_mem_usage=True,
    trust_remote_code=True).cuda().eval()

image = Image.open('./examples/image1.jpg').convert('RGB')

image_processor = CLIPImageProcessor.from_pretrained('OpenGVLab/InternViT-6B-448px-V1-5')

pixel_values = image_processor(images=image, return_tensors='pt').pixel_values
pixel_values = pixel_values.to(torch.bfloat16).cuda()

outputs = model(pixel_values)

hgdhrt avatar May 20 '24 07:05 hgdhrt

您好,readme写的不够好,给您带来困扰了。 请使用这里的load_image函数加载图像并进行切图,然后再送入ViT:

https://huggingface.co/OpenGVLab/InternVL-Chat-V1-5#model-usage

czczup avatar May 30 '24 16:05 czczup

This issue has been inactive for two months, so I am closing it. If you have any further questions or encounter any problems, please feel free to reopen it. Thank you!

czczup avatar Jul 31 '24 04:07 czczup