diff --git a/inference/core/entities/requests/groundingdino.py b/inference/core/entities/requests/groundingdino.py index d2d7f0af9..02941e439 100644 --- a/inference/core/entities/requests/groundingdino.py +++ b/inference/core/entities/requests/groundingdino.py @@ -3,6 +3,7 @@ from inference.core.entities.requests.dynamic_class_base import ( DynamicClassBaseInferenceRequest, ) +from inference.core.env import CLASS_AGNOSTIC_NMS class GroundingDINOInferenceRequest(DynamicClassBaseInferenceRequest): @@ -15,3 +16,4 @@ class GroundingDINOInferenceRequest(DynamicClassBaseInferenceRequest): box_threshold: Optional[float] = 0.5 grounding_dino_version_id: Optional[str] = "default" text_threshold: Optional[float] = 0.5 + class_agnostic_nms: Optional[bool] = CLASS_AGNOSTIC_NMS diff --git a/inference/core/models/classification_base.py b/inference/core/models/classification_base.py index ca5ba0cda..3d4c47019 100644 --- a/inference/core/models/classification_base.py +++ b/inference/core/models/classification_base.py @@ -136,6 +136,7 @@ def infer( Args: image (Any): The image or list of images to be processed. + - can be a BGR numpy array, filepath, InferenceRequestImage, PIL Image, byte-string, etc. disable_preproc_auto_orient (bool, optional): If true, the auto orient preprocessing step is disabled for this call. Default is False. disable_preproc_contrast (bool, optional): If true, the auto contrast preprocessing step is disabled for this call. Default is False. disable_preproc_grayscale (bool, optional): If true, the grayscale preprocessing step is disabled for this call. Default is False. diff --git a/inference/models/grounding_dino/grounding_dino.py b/inference/models/grounding_dino/grounding_dino.py index 7447feb9e..b35c9539c 100644 --- a/inference/models/grounding_dino/grounding_dino.py +++ b/inference/models/grounding_dino/grounding_dino.py @@ -42,9 +42,6 @@ def __init__( GROUNDING_DINO_CONFIG_PATH = os.path.join( GROUNDING_DINO_CACHE_DIR, "GroundingDINO_SwinT_OGC.py" ) - # GROUNDING_DINO_CHECKPOINT_PATH = os.path.join( - # GROUDNING_DINO_CACHE_DIR, "groundingdino_swint_ogc.pth" - # ) if not os.path.exists(GROUNDING_DINO_CACHE_DIR): os.makedirs(GROUNDING_DINO_CACHE_DIR) @@ -53,10 +50,6 @@ def __init__( url = "https://raw.githubusercontent.com/roboflow/GroundingDINO/main/groundingdino/config/GroundingDINO_SwinT_OGC.py" urllib.request.urlretrieve(url, GROUNDING_DINO_CONFIG_PATH) - # if not os.path.exists(GROUNDING_DINO_CHECKPOINT_PATH): - # url = "https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth" - # urllib.request.urlretrieve(url, GROUNDING_DINO_CHECKPOINT_PATH) - self.model = Model( model_config_path=GROUNDING_DINO_CONFIG_PATH, model_checkpoint_path=os.path.join( @@ -95,6 +88,7 @@ def infer( class_filter: list = None, box_threshold=0.5, text_threshold=0.5, + class_agnostic_nms=CLASS_AGNOSTIC_NMS, **kwargs ): """ @@ -121,7 +115,7 @@ def infer( self.class_names = text - if CLASS_AGNOSTIC_NMS: + if class_agnostic_nms: detections = detections.with_nms(class_agnostic=True) else: detections = detections.with_nms()