动态分辨率技术允许模型根据输入图像的复杂度和处理需求,实时调整其处理的分辨率。在处理简单或者信息量较少的图像时,模型可能会采用较低的分辨率以减少计算量;在处理复杂或者细节丰富的图像时,模型则会采用更高的分辨率以捕获更多细节。
下面是 LLava-Next 中动态高分辨率的实现示意图,其实就是两个分支,一个是 split 切图,一个是 resize 直接对大图进行缩放,这是为了保留全局的语义信息。对于视觉编码模型的输入来说,动态高分辨率的切图比如切 4 张图,完了还要再加上 resize 的那张图,这样其实是 5 张图的输入。

从代码实现来说,下面的动态高分辨率的代码实现来自 InternVL2 的图片预处理,主要就是对动态高分辨率的处理,
# 忽略导入IMAGENET_MEAN = (0.485, 0.456, 0.406)IMAGENET_STD = (0.229, 0.224, 0.225)def build_transform(input_size):MEAN, STD = IMAGENET_MEAN, IMAGENET_STDtransform = T.Compose([T.Lambda(lambda img: img.convert('RGB') if img.mode != 'RGB' else img),T.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC),T.ToTensor(),T.Normalize(mean=MEAN, std=STD)])return transformdef find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_size):best_ratio_diff = float('inf')best_ratio = (1, 1)area = width * heightfor ratio in target_ratios:target_aspect_ratio = ratio[0] / ratio[1]ratio_diff = abs(aspect_ratio - target_aspect_ratio)if ratio_diff < best_ratio_diff:best_ratio_diff = ratio_diffbest_ratio = ratioelif ratio_diff == best_ratio_diff:if area > 0.5 * image_size * image_size * ratio[0] * ratio[1]:best_ratio = ratioreturn best_ratiodef dynamic_preprocess(image, min_num=1, max_num=12, image_size=448, use_thumbnail=False):orig_width, orig_height = image.sizeaspect_ratio = orig_width / orig_height# calculate the existing image aspect ratiotarget_ratios = set((i, j) for n in range(min_num, max_num + 1) for i in range(1, n + 1) for j in range(1, n + 1) ifi * j <= max_num and i * j >= min_num)target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])# find the closest aspect ratio to the targettarget_aspect_ratio = find_closest_aspect_ratio(aspect_ratio, target_ratios, orig_width, orig_height, image_size)# calculate the target width and heighttarget_width = image_size * target_aspect_ratio[0]target_height = image_size * target_aspect_ratio[1]blocks = target_aspect_ratio[0] * target_aspect_ratio[1]# resize the imageresized_img = image.resize((target_width, target_height))processed_images = []for i in range(blocks):box = ((i % (target_width // image_size)) * image_size,(i // (target_width // image_size)) * image_size,((i % (target_width // image_size)) + 1) * image_size,((i // (target_width // image_size)) + 1) * image_size)# split the imagesplit_img = resized_img.crop(box)processed_images.append(split_img)assert len(processed_images) == blocksif use_thumbnail and len(processed_images) != 1:thumbnail_img = image.resize((image_size, image_size))processed_images.append(thumbnail_img)return processed_imagesdef load_image(image_file, input_size=448, max_num=12):image = Image.open(image_file).convert('RGB')transform = build_transform(input_size=input_size)images = dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num)pixel_values = [transform(image) for image in images]pixel_values = torch.stack(pixel_values)return pixel_values
这段代码其实就是主要就是两个过程,首先是寻找最接近的宽高比,也就是 find_closest_aspect_ratio 函数在做的事情,然后就是动态预处理,包括了切割和缩放,最后进行拼接,结束,等待送入视觉编码模型。
好了,以上分享了 多模态大模型中的动态高分辨率,希望我的分享能对你的学习有一点帮助。
好文章,需要你的鼓励
太空物联网连接服务商Myriota宣布其HyperPulse连接平台正式商用,该平台结合公司5G非地面网络架构与从Viasat租赁的L波段容量。该平台采用波束跳跃技术,根据流量需求激活所需波束,优化电池供电物联网设备功耗。相比UltraLite服务,HyperPulse提供更低延迟和更高日数据传输量。服务将于12月15日在美国、墨西哥、巴西、澳大利亚和沙特正式上线。
昆仑万维Skywork AI团队开发的Skywork-R1V4是一款突破性的多模态AI助手,能够像侦探一样主动分析图像、上网搜索信息并将两种能力无缝结合。该系统仅通过3万个高质量样本的监督学习就实现了卓越性能,在多项测试中超越了更大规模的商业模型,证明了精妙设计比单纯扩大规模更重要,为AI助手的实用化发展指明了高效路径。
AMD与HPE宣布扩大合作,共同开发下一代开放式可扩展人工智能基础设施。HPE将成为首批采用AMD Helios机架规模AI架构的系统供应商,该架构整合了AMD EPYC处理器、Instinct GPU、Pensando网络技术和ROCm开源软件栈。Helios平台每机架可提供2.9 exaFLOPS的FP4性能,采用开放机架宽设计标准,旨在简化大规模AI集群部署。HPE计划2026年全球推出该解决方案。
香港科技大学研究团队开发出FlashVGGT技术,通过创新的"压缩代表"策略和分块递归推理机制,将3D重建速度提升10倍以上,能处理超过3000张图像的超长序列。该技术在保持重建质量的同时显著降低计算复杂度,为VR游戏、建筑测量、自动驾驶等领域提供更实用的3D重建解决方案。