DeCLIP-TPAMI / code /detection_trt /configs /fvit_tensorrt_fp16.py
xiaomoguhzz's picture
Upload code/detection_trt/configs/fvit_tensorrt_fp16.py with huggingface_hub
17d4c6d verified
# TensorRT FP16 部署配置
# 用于 DeCLIP (csa模式) 和 CLIP (vanilla模式) 检测器
# 后端配置
backend_config = dict(
type='tensorrt',
common_config=dict(
fp16_mode=True, # 启用 FP16 加速
max_workspace_size=1 << 30, # 1GB workspace
),
model_inputs=[
dict(
input_shapes=dict(
# 图像输入: [batch, channels, height, width]
input=dict(
min_shape=[1, 3, 560, 560],
opt_shape=[1, 3, 560, 560],
max_shape=[1, 3, 800, 1333],
)
)
)
]
)
# ONNX 配置
onnx_config = dict(
type='onnx',
export_params=True,
keep_initializers_as_inputs=False,
opset_version=17,
save_file='model.onnx',
input_names=['input'],
output_names=['roi_features', 'dense_features'],
input_shape=None,
optimize=True,
dynamic_axes={
'input': {
0: 'batch',
2: 'height',
3: 'width'
},
'roi_features': {
0: 'num_rois',
},
'dense_features': {
0: 'batch',
2: 'feat_height',
3: 'feat_width'
}
}
)
# 代码库配置 (用于自定义模块)
codebase_config = dict(
type='mmdet', # 使用 mmdet 代码库
task='ObjectDetection',
model_type='end2end',
post_processing=dict(
score_threshold=0.05,
confidence_threshold=0.005,
iou_threshold=0.5,
max_output_boxes_per_class=200,
pre_top_k=5000,
keep_top_k=100,
background_label_id=-1,
)
)
# EVA-CLIP ViT 特定配置
evaclip_config = dict(
# 模型变体
model_name='EVA02-CLIP-B-16', # 或 'EVA02-CLIP-L-14-336'
# 输入尺寸
image_size=560, # 检测任务使用的图像尺寸
patch_size=16,
# 特征模式
feature_mode='csa', # 'vanilla' for CLIP, 'csa' for DeCLIP
# RoPE 位置编码
use_rope=True,
# xformers (需要在 ONNX 导出时禁用)
disable_xformers=True,
)
# 模型路径配置
model_paths = dict(
# EVA-CLIP 预训练权重
evaclip_b16='/mnt/SSD8T/home/wjj/code/my_CLIPSelf/checkpoints/EVA02_CLIP_B_psz16_s8B.pt',
evaclip_l14_336='/mnt/SSD8T/home/wjj/code/my_CLIPSelf/checkpoints/EVA02_CLIP_L_psz14_336_s8B.pt',
# DeCLIP 微调权重 (需要根据实际路径修改)
declip_csa_b16=None, # 待填写
declip_csa_l14_336=None, # 待填写
)
# 数据配置
data_config = dict(
# COCO Panoptic 数据集路径
coco_root='/mnt/SSD8T/home/wjj/dataset/standard_coco',
train_ann='annotations/instances_train2017.json',
val_ann='annotations/panoptic_val2017.json',
train_img='train2017',
val_img='val2017',
panoptic_segm='annotations/panoptic_val2017',
# 文本嵌入缓存
embed_path='metadata/coco_panoptic_clip_hand_craft_EVACLIP_ViTB16.npy',
)
# Benchmark 配置
benchmark_config = dict(
# 测试轮数
warmup_rounds=10,
test_rounds=100,
# 批处理大小
batch_sizes=[1, 4, 8],
# 输入尺寸
input_sizes=[(560, 560), (640, 640), (800, 1333)],
# 是否同步 CUDA
sync_cuda=True,
)