File size: 802 Bytes
583456e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b92a792
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Copyright (c) Facebook, Inc. and its affiliates.
# Copyright (c) Meta Platforms, Inc. All Rights Reserved

from .text_template import (
    PredefinedPromptExtractor,
    ImageNetPromptExtractor,
    VILDPromptExtractor,
)
from .adapter import ClipAdapter, MaskFormerClipAdapter


def build_text_prompt(cfg):
    if cfg.TEXT_TEMPLATES == "predefined":
        text_templates = PredefinedPromptExtractor(cfg.PREDEFINED_PROMPT_TEMPLATES)
    elif cfg.TEXT_TEMPLATES == "imagenet":
        text_templates = ImageNetPromptExtractor()
    elif cfg.TEXT_TEMPLATES == "vild":
        text_templates = VILDPromptExtractor()
    else:
        raise NotImplementedError(
            "Prompt learner {} is not supported".format(cfg.TEXT_TEMPLATES)
        )
    return text_templates

from .clip import tokenize