MCPcopy Create free account
hub / github.com/Atrovast/THGS / encode_text

Method encode_text

gui/main.py:58–64  ·  view source on GitHub ↗
(self, text)

Source from the content-addressed store, hash-verified

56 self.device = torch.device("cuda")
57
58 def encode_text(self, text):
59 text = self.tokenizer([text] + self.canon).to(self.device)
60 with torch.no_grad():
61 text_features = self.clip_pretrained.encode_text(text).type(torch.float32)
62 text_features = (text_features / text_features.norm(dim=-1, keepdim=True)).to(self.device)
63 self.text_feature = text_features
64 # return text_features
65
66 def compute_similarity(self, semantic_feature):
67 logit = semantic_feature @ self.text_feature.T

Callers 1

trainingFunction · 0.95

Calls 2

toMethod · 0.45
encode_textMethod · 0.45

Tested by 1

trainingFunction · 0.76