From 7f3fd8f3186931fb03d5c8700180c1e82fd3da09 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 16 Jun 2024 23:22:10 +0200 Subject: [PATCH] feat: update GroundingDINO from SwinT (tiny) to SwinB (base) --- .../config/GroundingDINO_SwinB_cfg.py | 43 +++++++++++++++++++ extras/GroundingDINO/util/inference.py | 6 +-- 2 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 extras/GroundingDINO/config/GroundingDINO_SwinB_cfg.py diff --git a/extras/GroundingDINO/config/GroundingDINO_SwinB_cfg.py b/extras/GroundingDINO/config/GroundingDINO_SwinB_cfg.py new file mode 100644 index 00000000..bc2788a8 --- /dev/null +++ b/extras/GroundingDINO/config/GroundingDINO_SwinB_cfg.py @@ -0,0 +1,43 @@ +batch_size = 1 +modelname = "groundingdino" +backbone = "swin_B_384_22k" +position_embedding = "sine" +pe_temperatureH = 20 +pe_temperatureW = 20 +return_interm_indices = [1, 2, 3] +backbone_freeze_keywords = None +enc_layers = 6 +dec_layers = 6 +pre_norm = False +dim_feedforward = 2048 +hidden_dim = 256 +dropout = 0.0 +nheads = 8 +num_queries = 900 +query_dim = 4 +num_patterns = 0 +num_feature_levels = 4 +enc_n_points = 4 +dec_n_points = 4 +two_stage_type = "standard" +two_stage_bbox_embed_share = False +two_stage_class_embed_share = False +transformer_activation = "relu" +dec_pred_bbox_embed_share = True +dn_box_noise_scale = 1.0 +dn_label_noise_ratio = 0.5 +dn_label_coef = 1.0 +dn_bbox_coef = 1.0 +embed_init_tgt = True +dn_labelbook_size = 2000 +max_text_len = 256 +text_encoder_type = "bert-base-uncased" +use_text_enhancer = True +use_fusion_layer = True +use_checkpoint = True +use_transformer_ckpt = True +use_text_cross_attention = True +text_dropout = 0.0 +fusion_dropout = 0.0 +fusion_droppath = 0.1 +sub_sentence_present = True \ No newline at end of file diff --git a/extras/GroundingDINO/util/inference.py b/extras/GroundingDINO/util/inference.py index bc8b6429..11e1a77c 100644 --- a/extras/GroundingDINO/util/inference.py +++ b/extras/GroundingDINO/util/inference.py @@ -14,7 +14,7 @@ from groundingdino.util.inference import load_model, preprocess_caption, get_phr class GroundingDinoModel(Model): def __init__(self): - self.config_file = 'extras/GroundingDINO/config/GroundingDINO_SwinT_OGC.py' + self.config_file = 'extras/GroundingDINO/config/GroundingDINO_SwinB_cfg.py' self.model = None self.load_device = torch.device('cpu') self.offload_device = torch.device('cpu') @@ -28,8 +28,8 @@ class GroundingDinoModel(Model): ) -> Tuple[sv.Detections, torch.Tensor, torch.Tensor, List[str]]: if self.model is None: filename = load_file_from_url( - url="https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth", - file_name='groundingdino_swint_ogc.pth', + url="https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha2/groundingdino_swinb_cogcoor.pth", + file_name='groundingdino_swinb_cogcoor.pth', model_dir=path_inpaint) model = load_model(model_config_path=self.config_file, model_checkpoint_path=filename)