书生图像 - 大规模视觉基础模型

March 4, 2025 · View on GitHub

[English Version]

书生图像 - 大规模视觉基础模型

PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC

这个代码仓库是 InternImage: Exploring Large-Scale Vision Foundation Models with Deformable Convolutions 的官方实现。

[论文] [知乎专栏]

亮点

  • :thumbsup: 高达 30 亿参数的最强视觉通用主干模型
  • 🏆 图像分类标杆数据集 ImageNet 90.1% Top1准确率,开源模型中准确度最高
  • 🏆 物体检测标杆数据集 COCO 65.5 mAP,唯一超过 65 mAP 的模型

最新进展

  • 2024年1月22日: 🚀 在 InternImage 中支持了 DCNv4!
  • 2023年2月28日: 🚀 InternImage 被 CVPR 2023 接收!
  • 2022年11月18日: 🚀 基于 InternImage-XL 主干网络,BEVFormer v2 在nuScenes的纯视觉3D检测任务上取得了最佳性能 63.4 NDS
  • 2022年11月10日: 🚀 InternImage-H 在 COCO 目标检测任务上以 65.4 mAP 斩获冠军,是唯一突破 65.0 mAP 的超强物体检测模型!
  • 2022年11月10日: 🚀 InternImage-H 在 ADE20K 语义分割数据集上取得 62.9 mIoU 的SOTA性能!

项目功能

  • 各类下游任务
  • 支持 CVPR 2023 Workshop on End-to-End Autonomous Driving详见
  • 支持提取模型中间层特征,详见
  • 支持基于 DeepSpeed 的低成本训练,详见
  • DCNv3 算子预编译 .whl 包,详见
  • InternImage-H(1B)/G(3B)
  • 支持分类/检测/分割 TensorRT 推理
  • InternImage 系列分类代码
  • InternImage-T/S/B/L/XL ImageNet-1K 预训练模型
  • InternImage-L/XL ImageNet-22K 预训练模型
  • InternImage-T/S/B/L/XL 检测和实例分割模型
  • InternImage-T/S/B/L/XL 语义分割模型

简介

InternImage 是一个由上海人工智能实验室、清华大学等机构的研究人员提出的基于卷积神经网络(CNN)的视觉基础模型。与基于 Transformer 的网络不同,InternImage 以可变形卷积 DCNv3 作为核心算子,使模型不仅具有检测和分割等下游任务所需的动态有效感受野,而且能够进行自适应的空间聚合。

与 InternImage 相关的其他项目还包括:预训练算法 M3I-Pretraining,通用解码器 Uni-Perceiver 系列,以及自动驾驶感知通用编码器 BEVFormer 系列。

性能

  • 在图像分类标杆数据集 ImageNet 上,InternImage 仅基于公开数据便达到了 90.1% 的 Top-1 准确率。这是除谷歌与微软两个未公开模型及额外数据集外,唯一准确率超过 90.0% 的模型,同时也是世界上开源模型中 ImageNet 准确度最高,规模最大的模型;
  • 在物体检测标杆数据集 COCO 上,InternImage 取得了 65.5 的 mAP,是世界上唯一超过 65 mAP 的模型;
  • 在另外 16 个重要的视觉基础数据集(覆盖分类、检测和分割任务)上取得世界最好性能。

分类任务

图像分类 场景分类 长尾分类
ImageNetPlaces365Places 205iNaturalist 2018
90.161.271.792.6

检测任务

常规物体检测 长尾物体检测 自动驾驶物体检测 密集物体检测
COCOVOC 2007VOC 2012OpenImageLVIS minivalLVIS valBDD100KnuScenesCrowdHuman
65.594.097.274.165.863.238.864.897.2

分割任务

语义分割街景分割RGBD分割
ADE20KCOCO Stuff-10KPascal ContextCityScapesNYU Depth V2
62.959.670.387.068.1

已发布模型

开源视觉预训练模型
namepretrainresolution#paramdownload
InternImage-LImageNet-22K384x384223Mpth | hf
InternImage-XLImageNet-22K384x384335Mpth | hf
InternImage-HJoint 427M384x3841.08Bpth | hf
InternImage-GJoint 427M384x3843Bpth | hf
ImageNet-1K 图像分类
namepretrainresolutionacc@1#paramFLOPsdownload
InternImage-TImageNet-1K224x22483.530M5Gpth | hf | cfg
InternImage-SImageNet-1K224x22484.250M8Gpth | hf | cfg
InternImage-BImageNet-1K224x22484.997M16Gpth | hf | cfg
InternImage-LImageNet-22K384x38487.7223M108Gpth | hf | cfg
InternImage-XLImageNet-22K384x38488.0335M163Gpth | hf | cfg
InternImage-HJoint 427M640x64089.61.08B1478Gpth | hf | cfg
InternImage-GJoint 427M512x51290.13B2700Gpth | hf | cfg
COCO 目标检测和实例分割
backbonemethodschdbox mAPmask mAP#paramFLOPsdownload
InternImage-TMask R-CNN1x47.242.549M270Gckpt | cfg
InternImage-TMask R-CNN3x49.143.749M270Gckpt | cfg
InternImage-SMask R-CNN1x47.843.369M340Gckpt | cfg
InternImage-SMask R-CNN3x49.744.569M340Gckpt | cfg
InternImage-BMask R-CNN1x48.844.0115M501Gckpt | cfg
InternImage-BMask R-CNN3x50.344.8115M501Gckpt | cfg
InternImage-LCascade1x54.947.7277M1399Gckpt | cfg
InternImage-LCascade3x56.148.5277M1399Gckpt | cfg
InternImage-XLCascade1x55.348.1387M1782Gckpt | cfg
InternImage-XLCascade3x56.248.8387M1782Gckpt | cfg
backbonemethodbox mAP (val/test)#paramdownload
CB-InternImage-HDINO (TTA)65.0 / 65.42.18Bckpt | cfg
CB-InternImage-GDINO (TTA)65.3 / 65.56BTODO
ADE20K 语义分割
backbonemethodresolutionmIoU (ss/ms)#paramFLOPsdownload
InternImage-TUperNet512x51247.9 / 48.159M944Gckpt | cfg
InternImage-SUperNet512x51250.1 / 50.980M1017Gckpt | cfg
InternImage-BUperNet512x51250.8 / 51.3128M1185Gckpt | cfg
InternImage-LUperNet640x64053.9 / 54.1256M2526Gckpt | cfg
InternImage-XLUperNet640x64055.0 / 55.3368M3142Gckpt | cfg
InternImage-HUperNet896x89659.9 / 60.31.12B3566Gckpt | cfg
InternImage-HMask2Former896x89662.5 / 62.91.31B4635Gckpt | cfg
模型推理速度

Export classification model from pytorch to tensorrt

Export detection model from pytorch to tensorrt

Export segmentation model from pytorch to tensorrt

nameresolution#paramFLOPsbatch 1 FPS (TensorRT)
InternImage-T224x22430M5G156
InternImage-S224x22450M8G129
InternImage-B224x22497M16G116
InternImage-L384x384223M108G56
InternImage-XL384x384335M163G47

在使用 mmdeploy 将 PyTorch 模型转为 TensorRT 之前,请确保您已正确编译 DCNv3 的自定义算子,其安装方式如下:

export MMDEPLOY_DIR=/the/root/path/of/MMDeploy

# prepare our custom ops, you can find it at InternImage/tensorrt/modulated_deform_conv_v3
cp -r modulated_deform_conv_v3 ${MMDEPLOY_DIR}/csrc/mmdeploy/backend_ops/tensorrt

# build custom ops
cd ${MMDEPLOY_DIR}
mkdir -p build && cd build
cmake -DCMAKE_CXX_COMPILER=g++-7 -DMMDEPLOY_TARGET_BACKENDS=trt -DTENSORRT_DIR=${TENSORRT_DIR} -DCUDNN_DIR=${CUDNN_DIR} ..
make -j$(nproc) && make install

# install the mmdeploy after building custom ops
cd ${MMDEPLOY_DIR}
pip install -e .

关于 mmdeploy 编译自定义算子的更多细节,请参考这份文档

相关项目

多模态基础模型

  • Uni-Perceiver: 通用感知任务预训练统一框架, 可直接处理 zero-shot 和 few-shot 任务
  • Uni-Perceiver v2: 用于处理图像/图文任务的通用模型
  • M3I-Pretraining: 基于最大化输入和目标的互信息的单阶段预训练范式
  • InternVL: 领先的多模态大语言模型,在 OCR、多模态推理和对话等任务中表现卓越

自动驾驶

  • BEVFormer: 基于 BEV 的新一代纯视觉环视感知方案
  • BEVFormer v2: 融合 BEV 感知和透视图检测的两阶段检测器

算法竞赛

引用

若这个工作对您的研究有帮助,请参考如下 BibTeX 对我们的工作进行引用。

@inproceedings{wang2023internimage,
  title={Internimage: Exploring large-scale vision foundation models with deformable convolutions},
  author={Wang, Wenhai and Dai, Jifeng and Chen, Zhe and Huang, Zhenhang and Li, Zhiqi and Zhu, Xizhou and Hu, Xiaowei and Lu, Tong and Lu, Lewei and Li, Hongsheng and others},
  booktitle={Proceedings of the IEEE/CVF conference on computer vision and pattern recognition},
  pages={14408--14419},
  year={2023}
}