MCPcopy Create free account
hub / github.com/ace-step/ACE-Step / get_text_embeddings

Method get_text_embeddings

trainer.py:299–314  ·  view source on GitHub ↗
(self, texts, device, text_max_length=256)

Source from the content-addressed store, hash-verified

297 return mhubert_ssl_hidden_states_list
298
299 def get_text_embeddings(self, texts, device, text_max_length=256):
300 inputs = self.text_tokenizer(
301 texts,
302 return_tensors="pt",
303 padding=True,
304 truncation=True,
305 max_length=text_max_length,
306 )
307 inputs = {key: value.to(device) for key, value in inputs.items()}
308 if self.text_encoder_model.device != device:
309 self.text_encoder_model.to(device)
310 with torch.no_grad():
311 outputs = self.text_encoder_model(**inputs)
312 last_hidden_states = outputs.last_hidden_state
313 attention_mask = inputs["attention_mask"]
314 return last_hidden_states, attention_mask
315
316 def preprocess(self, batch, train=True):
317 target_wavs = batch["target_wavs"]

Callers 1

preprocessMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected