MCPcopy Create free account
hub / github.com/WeChatCV/WeVisionOne / __init__

Method __init__

WeVisionOne/language/clip.py:14–29  ·  view source on GitHub ↗
(self, cfg, input_shape)

Source from the content-addressed store, hash-verified

12@BACKBONE_REGISTRY.register()
13class CLIPLangEncoder(Backbone):
14 def __init__(self, cfg, input_shape):
15 super().__init__()
16
17 text_cfg = cfg.MODEL.TEXT
18
19 model_name = text_cfg.MODEL_NAME
20 token_name = text_cfg.TOKEN_NAME
21
22 self.tokenizer = AutoTokenizer.from_pretrained(token_name)
23 clip_config = CLIPTextConfig.from_pretrained(model_name)
24 # attention_dropout=dropout)
25 if 'CLIP-ViT-L-14-laion2B-s32B-b82K' in model_name:
26 clip_config.projection_dim = 768
27
28 # self.model = CLIPTP.from_pretrained(model_name, config=clip_config)
29 self.model = CLIPTP(config=clip_config)
30
31 def forward(self, text):
32 num_per_batch = [len(t) for t in text]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected