SpecAugment icon indicating copy to clipboard operation
SpecAugment copied to clipboard

ModuleNotFoundError when importing

Open katrin-ibrahim opened this issue 3 years ago • 1 comments

ModuleNotFoundError Traceback (most recent call last) in () 32 import librosa, librosa.display 33 from audiomentations import Compose, AddGaussianNoise, FrequencyMask, TimeStretch, PitchShift, Shift ---> 34 from specAugment import spec_augment_tensorflow 35 import IPython 36 import soundfile as sf

/usr/local/lib/python3.7/dist-packages/specAugment/spec_augment_tensorflow.py in () 39 import librosa.display 40 import tensorflow as tf ---> 41 from tensorflow.contrib.image import sparse_image_warp 42 import numpy as np 43 import random

ModuleNotFoundError: No module named 'tensorflow.contrib'

katrin-ibrahim avatar May 22 '22 15:05 katrin-ibrahim

this code is using an older version of tensorflow, here are some edits i made to spec_augment_tensorflow.py to make it compatible with tensorflow 2.9.1:

change line 40 import statement "import tensorflow as tf" to "import tensorflow.compat.v1 as tf" change line 41 import statement "from tensorflow.contrib.image import sparse_image_warp" to "from tensorflow_addons.image import sparse_image_warp"

This still threw an error about "eager execution" wrt the "placeholder" function when trying to run the "spec_augment" function. I fixed it by inserting the command "tf.disable_eager_execution" on line 75 before the call of the placeholder function.

rockamondo avatar Jun 16 '22 19:06 rockamondo