Skip to content

Commit

Permalink
Merge pull request #704 from roboflow/fix/tasks_descriptions_in_parsers
Browse files Browse the repository at this point in the history
Add descriptions to task types in `VLM as Detector`
  • Loading branch information
PawelPeczek-Roboflow authored Oct 3, 2024
2 parents 489c242 + 1f8902f commit f2cc3b5
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from inference.core.workflows.core_steps.common.utils import (
attach_parents_coordinates_to_sv_detections,
)
from inference.core.workflows.core_steps.common.vlms import VLM_TASKS_METADATA
from inference.core.workflows.execution_engine.constants import (
DETECTION_ID_KEY,
IMAGE_DIMENSIONS_KEY,
Expand Down Expand Up @@ -67,6 +68,18 @@

SHORT_DESCRIPTION = "Parses raw string into object-detection prediction."

SUPPORTED_TASKS = {
"object-detection",
"object-detection-and-caption",
"open-vocabulary-object-detection",
"phrase-grounded-object-detection",
"region-proposal",
"ocr-with-text-detection",
}
RELEVANT_TASKS_METADATA = {
k: v for k, v in VLM_TASKS_METADATA.items() if k in SUPPORTED_TASKS
}


class BlockManifest(WorkflowBlockManifest):
model_config = ConfigDict(
Expand Down Expand Up @@ -112,14 +125,12 @@ class BlockManifest(WorkflowBlockManifest):
description="Type of the model that generated prediction",
examples=[["google-gemini", "anthropic-claude", "florence-2"]],
)
task_type: Literal[
"object-detection",
"object-detection-and-caption",
"open-vocabulary-object-detection",
"phrase-grounded-object-detection",
"region-proposal",
"ocr-with-text-detection",
]
task_type: Literal[tuple(SUPPORTED_TASKS)] = Field(
description="Task type to performed by model.",
json_schema_extra={
"values_metadata": RELEVANT_TASKS_METADATA,
},
)

@model_validator(mode="after")
def validate(self) -> "BlockManifest":
Expand Down

0 comments on commit f2cc3b5

Please sign in to comment.