ViTDetBackbone 类keras_cv.models.ViTDetBackbone(
include_rescaling,
input_shape=(1024, 1024, 3),
input_tensor=None,
patch_size=16,
embed_dim=768,
depth=12,
mlp_dim=3072,
num_heads=12,
out_chans=256,
use_bias=True,
use_abs_pos=True,
use_rel_pos=True,
window_size=14,
global_attention_indices=[2, 5, 8, 11],
layer_norm_epsilon=1e-06,
**kwargs
)
使用窗口化 Transformer 编码器和相对位置编码的 ViT 图像编码器。
参数
(H, W, C)。默认为 (1024, 1024, 3)。keras.layers.Input() 的输出。默认为 None。True,则输入将通过 Rescaling(1/255.0) 层。默认为 False。16。768。12。768*4。MultiHeadAttentionWithRelativePE 层中使用的头的数量。默认为 12。256。True。True。True。14。[2, 5, 8, 11]。1e-6。参考文献
from_preset 方法ViTDetBackbone.from_preset()
从预设配置和权重实例化 ViTDetBackbone 模型。
参数
None,遵循预设是否有可用的预训练权重。示例
# Load architecture and weights from preset
model = keras_cv.models.ViTDetBackbone.from_preset(
"vitdet_base_sa1b",
)
# Load randomly initialized model from preset architecture with weights
model = keras_cv.models.ViTDetBackbone.from_preset(
"vitdet_base_sa1b",
load_weights=False,
| 预设名称 | 参数 | 描述 |
|---|---|---|
| vitdet_base | 8967万 | Detectron2 ViT 主干网络,具有 12 个 Transformer 编码器,嵌入维度为 768,注意力层具有 12 个头,在编码器 2、5、8 和 11 上使用全局注意力。 |
| vitdet_large | 3亿800万 | Detectron2 ViT 主干网络,具有 24 个 Transformer 编码器,嵌入维度为 1024,注意力层具有 16 个头,在编码器 5、11、17 和 23 上使用全局注意力。 |
| vitdet_huge | 6亿3700万 | Detectron2 ViT 主干网络模型,具有 32 个 Transformer 编码器,嵌入维度为 1280,注意力层具有 16 个头,在编码器 7、15、23 和 31 上使用全局注意力。 |
| vitdet_base_sa1b | 8967万 | 在 SA1B 数据集上训练的基本 Detectron2 ViT 主干网络。 |
| vitdet_large_sa1b | 3亿800万 | 在 SA1B 数据集上训练的大型 Detectron2 ViT 主干网络。 |
| vitdet_huge_sa1b | 6亿3700万 | 在 SA1B 数据集上训练的超大型 Detectron2 ViT 主干网络。 |
ViTDetBBackbone 类keras_cv.models.ViTDetBBackbone(
include_rescaling,
input_shape=(1024, 1024, 3),
input_tensor=None,
patch_size=16,
embed_dim=768,
depth=12,
mlp_dim=3072,
num_heads=12,
out_chans=256,
use_bias=True,
use_abs_pos=True,
use_rel_pos=True,
window_size=14,
global_attention_indices=[2, 5, 8, 11],
layer_norm_epsilon=1e-06,
**kwargs
)
VitDetBBackbone 模型。
参考
对于迁移学习用例,请务必阅读迁移学习和微调指南。
示例
input_data = np.ones(shape=(1, 1024, 1024, 3))
# Randomly initialized backbone
model = VitDetBBackbone()
output = model(input_data)
ViTDetLBackbone 类keras_cv.models.ViTDetLBackbone(
include_rescaling,
input_shape=(1024, 1024, 3),
input_tensor=None,
patch_size=16,
embed_dim=768,
depth=12,
mlp_dim=3072,
num_heads=12,
out_chans=256,
use_bias=True,
use_abs_pos=True,
use_rel_pos=True,
window_size=14,
global_attention_indices=[2, 5, 8, 11],
layer_norm_epsilon=1e-06,
**kwargs
)
VitDetLBackbone 模型。
参考
对于迁移学习用例,请务必阅读迁移学习和微调指南。
示例
input_data = np.ones(shape=(1, 1024, 1024, 3))
# Randomly initialized backbone
model = VitDetLBackbone()
output = model(input_data)
ViTDetHBackbone 类keras_cv.models.ViTDetHBackbone(
include_rescaling,
input_shape=(1024, 1024, 3),
input_tensor=None,
patch_size=16,
embed_dim=768,
depth=12,
mlp_dim=3072,
num_heads=12,
out_chans=256,
use_bias=True,
use_abs_pos=True,
use_rel_pos=True,
window_size=14,
global_attention_indices=[2, 5, 8, 11],
layer_norm_epsilon=1e-06,
**kwargs
)
VitDetHBackbone 模型。
参考
对于迁移学习用例,请务必阅读迁移学习和微调指南。
示例
input_data = np.ones(shape=(1, 1024, 1024, 3))
# Randomly initialized backbone
model = VitDetHBackbone()
output = model(input_data)