Skip to content

Commit

Permalink
Fix child pipeline config initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
botirk38 committed Sep 6, 2024
1 parent 6de6dce commit 3c6b693
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions huggingface_pipelines/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class HFAudioToEmbeddingPipeline(Pipeline):
pipeline = HFAudioToEmbeddingPipeline(pipeline_config)
"""

config: HFAudioToEmbeddingPipelineConfig

def __init__(self, config: HFAudioToEmbeddingPipelineConfig):
"""
Initialize the HFAudioToEmbeddingPipeline.
Expand Down Expand Up @@ -238,14 +240,16 @@ def process_batch(self, batch: Dict[str, Any]) -> Dict[str, Any]:
try:
for column in self.config.columns:
if column not in batch:
logger.warning(f"Column {column} not found in batch. Skipping.")
logger.warning(
f"Column {column} not found in batch. Skipping.")
continue

audio_inputs = self.collect_valid_audio_inputs(batch[column])

if not audio_inputs:

raise ValueError(f"No valid audio inputs found in column {column}/")
raise ValueError(
f"No valid audio inputs found in column {column}/")

try:

Expand All @@ -255,7 +259,7 @@ def process_batch(self, batch: Dict[str, Any]) -> Dict[str, Any]:

batch_inputs = [
tensor.to(self.config.device)
for tensor in audio_inputs[i : i + self.config.batch_size]
for tensor in audio_inputs[i: i + self.config.batch_size]
]

batch_embeddings = self.model.predict(
Expand Down

0 comments on commit 3c6b693

Please sign in to comment.