GroundingDINO
GroundingDINO copied to clipboard
'GroundingDINO' object has no attribute 'predict_with_caption'
while working on GroundingDINO with SAM here is the notebook: https://colab.research.google.com/drive/1uObAs_PI6caKHhwZRN3mQSzkc3zxrkeR?usp=sharing
detections, phrases = model.predict_with_caption(
image=image_bgr,
caption=TEXT_PROMPT,
box_threshold=BOX_THRESHOLD,
text_threshold=TEXT_THRESHOLD,
)
giving error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
[<ipython-input-52-a4301172c7a0>](https://localhost:8080/#) in <cell line: 1>()
----> 1 detections, phrases = model.predict_with_caption(
2 image=image_bgr,
3 caption=TEXT_PROMPT,
4 box_threshold=BOX_THRESHOLD,
5 text_threshold=TEXT_THRESHOLD,
[/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py](https://localhost:8080/#) in __getattr__(self, name)
1612 if name in modules:
1613 return modules[name]
-> 1614 raise AttributeError("'{}' object has no attribute '{}'".format(
1615 type(self).__name__, name))
1616
AttributeError: 'GroundingDINO' object has no attribute 'predict_with_caption'
Looking forward to hearing from you. Thanks
I thinks it's because you didn't initialized the model Class. This should be working:
from groundingdino.util.inference import Model
GROUNDING_DINO_CONFIG_PATH = "../groundingdino/config/GroundingDINO_SwinT_OGC.py"
GROUNDING_DINO_CHECKPOINT_PATH = "../weights/groundingdino_swint_ogc.pth"
grounding_dino_model = Model(model_config_path=GROUNDING_DINO_CONFIG_PATH, model_checkpoint_path=GROUNDING_DINO_CHECKPOINT_PATH)
detections, phrases = grounding_dino_model.predict_with_caption(
image=image_np,
caption=CAPTION,
box_threshold=BOX_THRESHOLD,
text_threshold=TEXT_THRESHOLD
)