MCPcopy Create free account
hub / github.com/FunAudioLLM/FunMusic / static_batch

Function static_batch

inspiremusic/dataset/processor.py:375–396  ·  view source on GitHub ↗

Static batch the data by `batch_size` Args: data: Iterable[{key, feat, label}] batch_size: batch size Returns: Iterable[List[{key, feat, label}]]

(data, batch_size=32)

Source from the content-addressed store, hash-verified

373
374
375def static_batch(data, batch_size=32):
376 """ Static batch the data by `batch_size`
377
378 Args:
379 data: Iterable[{key, feat, label}]
380 batch_size: batch size
381
382 Returns:
383 Iterable[List[{key, feat, label}]]
384 """
385 buf = []
386 data_empty = True
387 for sample in data:
388 data_empty = False
389 buf.append(sample)
390 if len(buf) >= batch_size:
391 yield buf
392 buf = []
393 if data_empty:
394 raise ValueError("data is empty")
395 if len(buf) > 0:
396 yield buf
397
398
399def dynamic_batch(data, max_frames_in_batch=12000, mode='train'):

Callers 1

batchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected