Skip to content

A lightweight yet powerful audio-to-MIDI converter with pitch bend detection

convert tf.debugging.assert_none_equal to standard assert for single value checks, remove model train callback test bc basically duplicate with more work.

Benjie Genchele2f68fc27627
diff --git a/basic_pitch/data/tf_example_deserialization.py b/basic_pitch/data/tf_example_deserialization.py
index acb2f99..ffaeb73 100644
--- a/basic_pitch/data/tf_example_deserialization.py
+++ b/basic_pitch/data/tf_example_deserialization.py
@@ -73,10 +73,7 @@ def prepare_datasets(
# check that the base dataset returned by ds_function is FINITE
for ds in [ds_train, ds_validation]:
- tf.debugging.assert_none_equal(
- tf.cast(tf.data.experimental.cardinality(ds), tf.int32),
- tf.data.experimental.INFINITE_CARDINALITY,
- )
+ assert tf.cast(tf.data.experimental.cardinality(ds), tf.int32) != tf.data.experimental.INFINITE_CARDINALITY
# training dataset
if training_shuffle_buffer_size > 0:
@@ -137,10 +134,7 @@ def prepare_visualization_datasets(
# check that the base dataset returned by ds_function is FINITE
for ds in [ds_train, ds_validation]:
- tf.debugging.assert_none_equal(
- tf.cast(tf.data.experimental.cardinality(ds), tf.int32),
- tf.data.experimental.INFINITE_CARDINALITY,
- )
+ assert tf.cast(tf.data.experimental.cardinality(ds), tf.int32) != tf.data.experimental.INFINITE_CARDINALITY
# training dataset
ds_train = ds_train.repeat().batch(batch_size).prefetch(tf.data.AUTOTUNE)
diff --git a/tests/test_callbacks.py b/tests/test_callbacks.py
index bf3929e..e5f5788 100644
--- a/tests/test_callbacks.py
+++ b/tests/test_callbacks.py
@@ -24,8 +24,6 @@ from typing import Dict
from basic_pitch.callbacks import VisualizeCallback
from basic_pitch.constants import AUDIO_N_SAMPLES, ANNOTATIONS_N_SEMITONES, ANNOT_N_FRAMES
-os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
-
class MockModel(tf.keras.Model):
def __init__(self) -> None:
@@ -62,27 +60,3 @@ def test_visualize_callback_on_epoch_end(tmpdir: str) -> None:
vc.model = MockModel()
vc.on_epoch_end(1, {"loss": np.random.random(), "val_loss": np.random.random()})
-
-
-def test_visualize_callback_on_epoch_end_with_model(tmpdir: str) -> None:
- model = MockModel()
- model.compile(optimizer="adam", loss="mse")
-
- batch_size = 2 # needs to be at least 2 bc validation_split required
-
- x_train = np.random.random((batch_size, AUDIO_N_SAMPLES, 1))
- y_train = {
- key: np.random.random((batch_size, ANNOTATIONS_N_SEMITONES, ANNOT_N_FRAMES))
- for key in ["onset", "contour", "note"]
- }
-
- vc = VisualizeCallback(
- train_ds=create_mock_dataset(),
- validation_ds=create_mock_dataset(),
- tensorboard_dir=str(tmpdir),
- original_validation_ds=create_mock_dataset(),
- contours=True,
- )
-
- history = model.fit(x_train, y_train, epochs=1, validation_split=0.5, callbacks=[vc], verbose=0)
- assert history