Skip to content

Caption Ontology

Bases: DetectionOntology

Source code in autodistill/detection/caption_ontology.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
@dataclass
class CaptionOntology(DetectionOntology):
    promptMap: List[Tuple[str, str]]

    def __init__(self, ontology: Dict[str, str]):
        self.promptMap = [(k, v) for k, v in ontology.items()]

        if len(self.promptMap) == 0:
            raise ValueError("Ontology is empty")

    def prompts(self) -> List[str]:
        return super().prompts()

    def classToPrompt(self, cls: str) -> str:
        return super().classToPrompt(cls)