MCPcopy
hub / github.com/Audio-AGI/AudioSep / get_text_embedding

Method get_text_embedding

models/CLAP/open_clip/model.py:732–752  ·  view source on GitHub ↗

Get the text embedding from the model Parameters ---------- data: torch.Tensor a tensor of text embedding Returns ---------- text_embed: torch.Tensor a tensor of text_embeds (N, D)

(self, data)

Source from the content-addressed store, hash-verified

730 return self.logit_scale_a.exp(), self.logit_scale_t.exp()
731
732 def get_text_embedding(self, data):
733 """Get the text embedding from the model
734
735 Parameters
736 ----------
737 data: torch.Tensor
738 a tensor of text embedding
739
740 Returns
741 ----------
742 text_embed: torch.Tensor
743 a tensor of text_embeds (N, D)
744
745 """
746 device = next(self.parameters()).device
747 for k in data:
748 data[k] = data[k].to(device)
749 text_embeds = self.encode_text(data, device=device)
750 text_embeds = F.normalize(text_embeds, dim=-1)
751
752 return text_embeds
753
754 def get_audio_embedding(self, data):
755 """Get the audio embedding from the model

Callers 2

_get_text_embedMethod · 0.80
infer_textFunction · 0.80

Calls 1

encode_textMethod · 0.95

Tested by

no test coverage detected