Skip to content

Commit 0b50b50

Browse files
committed
load swinb dino
1 parent d48caa5 commit 0b50b50

File tree

1 file changed

+118
-4
lines changed

1 file changed

+118
-4
lines changed

examples/enrichment-ram-groundingdino-sam.ipynb

Lines changed: 118 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@
718718
},
719719
{
720720
"cell_type": "code",
721-
"execution_count": 11,
721+
"execution_count": 32,
722722
"id": "5cc1e1b8-799c-461f-b08e-a95590be9a60",
723723
"metadata": {
724724
"tags": []
@@ -768,8 +768,8 @@
768768
},
769769
{
770770
"cell_type": "code",
771-
"execution_count": 12,
772-
"id": "9fdd1d2f-4df4-422d-89a7-bbec9bf8a1dc",
771+
"execution_count": 33,
772+
"id": "49f8a1b8-5542-48ee-9b78-ae653640c38c",
773773
"metadata": {
774774
"tags": []
775775
},
@@ -794,7 +794,121 @@
794794
" (2.35, 277.69, 637.63, 425.32)]}"
795795
]
796796
},
797-
"execution_count": 12,
797+
"execution_count": 33,
798+
"metadata": {},
799+
"output_type": "execute_result"
800+
}
801+
],
802+
"source": [
803+
"results"
804+
]
805+
},
806+
{
807+
"cell_type": "markdown",
808+
"id": "55d02a9a-32c1-430d-8ca8-ca10ac4b8712",
809+
"metadata": {},
810+
"source": [
811+
"Load another SwinB variant of Grounding DINO. Weights and config can be downloaded from the [official Grounding DINO repo](https://github.com/IDEA-Research/GroundingDINO)."
812+
]
813+
},
814+
{
815+
"cell_type": "code",
816+
"execution_count": 30,
817+
"id": "330f87fa-fa3f-416d-a2cd-a63b52a3d8f1",
818+
"metadata": {
819+
"tags": []
820+
},
821+
"outputs": [
822+
{
823+
"name": "stderr",
824+
"output_type": "stream",
825+
"text": [
826+
"INFO:fastdup.models.grounding_dino:Loading model checkpoint from - groundingdino_swinb_cogcoor.pth\n"
827+
]
828+
},
829+
{
830+
"name": "stdout",
831+
"output_type": "stream",
832+
"text": [
833+
"final text_encoder_type: bert-base-uncased\n"
834+
]
835+
},
836+
{
837+
"name": "stderr",
838+
"output_type": "stream",
839+
"text": [
840+
"Some weights of the model checkpoint at bert-base-uncased were not used when initializing BertModel: ['cls.predictions.bias', 'cls.predictions.transform.dense.bias', 'cls.predictions.transform.dense.weight', 'cls.predictions.transform.LayerNorm.bias', 'cls.seq_relationship.weight', 'cls.predictions.transform.LayerNorm.weight', 'cls.seq_relationship.bias']\n",
841+
"- This IS expected if you are initializing BertModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n",
842+
"- This IS NOT expected if you are initializing BertModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n",
843+
"INFO:fastdup.models.grounding_dino:Model loaded on device - cuda\n"
844+
]
845+
},
846+
{
847+
"name": "stdout",
848+
"output_type": "stream",
849+
"text": [
850+
"final text_encoder_type: bert-base-uncased\n"
851+
]
852+
}
853+
],
854+
"source": [
855+
"model = GroundingDINO(model_config=\"GroundingDINO_SwinB_cfg.py\", model_weights=\"groundingdino_swinb_cogcoor.pth\")\n",
856+
"results = model.run_inference(image_path=\"coco_minitrain_25k/images/val2017/000000449996.jpg\",\n",
857+
" text_prompt=\"air field . airliner . plane . airport . airport runway . airport terminal . jet . land . park . raceway . sky . tarmac . terminal\",\n",
858+
" box_threshold=0.3,\n",
859+
" text_threshold=0.25)"
860+
]
861+
},
862+
{
863+
"cell_type": "code",
864+
"execution_count": 31,
865+
"id": "9fdd1d2f-4df4-422d-89a7-bbec9bf8a1dc",
866+
"metadata": {
867+
"tags": []
868+
},
869+
"outputs": [
870+
{
871+
"data": {
872+
"text/plain": [
873+
"{'labels': ['sky',\n",
874+
" 'plane',\n",
875+
" 'plane',\n",
876+
" 'plane',\n",
877+
" 'plane',\n",
878+
" 'jet',\n",
879+
" 'jet',\n",
880+
" 'jet',\n",
881+
" 'plane',\n",
882+
" 'jet',\n",
883+
" 'plane',\n",
884+
" 'tarmac'],\n",
885+
" 'scores': [0.6725,\n",
886+
" 0.5171,\n",
887+
" 0.5012,\n",
888+
" 0.5205,\n",
889+
" 0.4961,\n",
890+
" 0.448,\n",
891+
" 0.3454,\n",
892+
" 0.3646,\n",
893+
" 0.4127,\n",
894+
" 0.3492,\n",
895+
" 0.3438,\n",
896+
" 0.3614],\n",
897+
" 'boxes': [(0.8, 0.64, 639.07, 243.63),\n",
898+
" (143.06, 248.17, 261.81, 296.37),\n",
899+
" (444.0, 112.47, 496.71, 129.99),\n",
900+
" (113.93, 289.86, 244.38, 340.29),\n",
901+
" (392.88, 272.05, 463.05, 294.73),\n",
902+
" (114.1, 290.14, 244.1, 340.02),\n",
903+
" (393.09, 272.23, 462.76, 294.51),\n",
904+
" (143.47, 248.59, 261.61, 296.13),\n",
905+
" (551.81, 258.11, 639.07, 297.51),\n",
906+
" (444.24, 112.87, 496.45, 129.68),\n",
907+
" (501.01, 282.23, 558.72, 296.47),\n",
908+
" (1.46, 274.81, 638.57, 426.26)]}"
909+
]
910+
},
911+
"execution_count": 31,
798912
"metadata": {},
799913
"output_type": "execute_result"
800914
}

0 commit comments

Comments
 (0)