[Python] Tensorflow Graph is finalized and cannot be modified

Discussão em 'Python' iniciado por Stack, Julho 21, 2025.

  1. Stack

    Stack Membro Participativo

    this is my code:

    vocals_path = "output/song.wav"
    audio_path = vocals_path
    from inaSpeechSegmenter import Segmenter
    import tensorflow as tf

    # Initialize the segmenter
    seg = Segmenter()

    # Analyze the audio file
    segments = seg(vocals_path)

    # Print the segments
    for segment in segments:
    print(segment)


    this is error:

    File "/root/code/aimusic/essgender.py", line 138, in <module>
    seg = Segmenter()
    ^^^^^^^^^^^
    File "/root/code/aimusic/venv/lib/python3.11/site-packages/inaSpeechSegmenter/segmenter.py", line 241, in __init__
    self.vad = SpeechMusicNoise(batch_size)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/root/code/aimusic/venv/lib/python3.11/site-packages/inaSpeechSegmenter/segmenter.py", line 131, in __init__
    self.nn = keras.models.load_model(model_path, compile=False)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/root/code/aimusic/venv/lib/python3.11/site-packages/keras/saving/saving_api.py", line 212, in load_model
    return legacy_sm_saving_lib.load_model(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/root/code/aimusic/venv/lib/python3.11/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler
    raise e.with_traceback(filtered_tb) from None
    File "/root/code/aimusic/venv/lib/python3.11/site-packages/tensorflow/python/framework/ops.py", line 3375, in _check_not_finalized
    raise RuntimeError("Graph is finalized and cannot be modified.")
    RuntimeError: Graph is finalized and cannot be modified.


    I've tried to manually reset graph like this:

    tf.compat.v1.reset_default_graph()


    or like this

    from tensorflow.python.framework import ops
    ops.reset_default_graph()
    sess = tf.InteractiveSession()


    But didn't work(same error).

    What do I do?

    Continue reading...

Compartilhe esta Página