From 4f04acf4c87bf30956df2a683574186069bc5727 Mon Sep 17 00:00:00 2001 From: captainfffsama Date: Mon, 10 Apr 2023 17:16:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9C=AC=E5=9C=B0=E7=9A=84hu?= =?UTF-8?q?ggingface?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + demo/inference_on_a_image.py | 1 + groundingdino/util/get_tokenlizer.py | 4 ++++ groundingdino/version.py | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fdc0e71..bc5ad2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +test_weight/ # IDE .idea/ .vscode/ diff --git a/demo/inference_on_a_image.py b/demo/inference_on_a_image.py index 62546d7..51e2634 100644 --- a/demo/inference_on_a_image.py +++ b/demo/inference_on_a_image.py @@ -27,6 +27,7 @@ def plot_boxes_to_image(image_pil, tgt): for box, label in zip(boxes, labels): # from 0..1 to 0..W, 0..H box = box * torch.Tensor([W, H, W, H]) + print("label:",label) # from xywh to xyxy box[:2] -= box[2:] / 2 box[2:] += box[:2] diff --git a/groundingdino/util/get_tokenlizer.py b/groundingdino/util/get_tokenlizer.py index f7dcf7e..bb6ed4f 100644 --- a/groundingdino/util/get_tokenlizer.py +++ b/groundingdino/util/get_tokenlizer.py @@ -1,3 +1,4 @@ +import os from transformers import AutoTokenizer, BertModel, BertTokenizer, RobertaModel, RobertaTokenizerFast @@ -23,4 +24,7 @@ def get_pretrained_language_model(text_encoder_type): return BertModel.from_pretrained(text_encoder_type) if text_encoder_type == "roberta-base": return RobertaModel.from_pretrained(text_encoder_type) + + if os.path.isdir(text_encoder_type): + return BertModel.from_pretrained(text_encoder_type) raise ValueError("Unknown text_encoder_type {}".format(text_encoder_type)) diff --git a/groundingdino/version.py b/groundingdino/version.py index 3dc1f76..b794fd4 100644 --- a/groundingdino/version.py +++ b/groundingdino/version.py @@ -1 +1 @@ -__version__ = "0.1.0" +__version__ = '0.1.0'