MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / extract_mean_emb

Method extract_mean_emb

semantic_sam/language/encoder.py:86–93  ·  view source on GitHub ↗
(txts)

Source from the content-addressed store, hash-verified

84 else:
85 with torch.no_grad():
86 def extract_mean_emb(txts):
87 tokens = self.tokenizer(
88 txts, padding='max_length', truncation=True, max_length=self.max_token_num, return_tensors='pt'
89 )
90 clss_embedding = self.forward_language((tokens['input_ids'].cuda(), tokens['attention_mask'].cuda()), norm=norm)
91 clss_embedding = clss_embedding.mean(dim=0)
92 clss_embedding /= clss_embedding.norm()
93 return clss_embedding
94
95 templates = get_prompt_templates()
96 clss_embeddings = []

Callers

nothing calls this directly

Calls 1

forward_languageMethod · 0.95

Tested by

no test coverage detected