turicreate icon indicating copy to clipboard operation
turicreate copied to clipboard

"Incompatible with layer vggish" running Introductory Example

Open ananasn opened this issue 3 years ago • 3 comments

I've faced difficulties running "Introductory Example" from the documentation.

I use ESC-50 dataset.

Package versions:

  • tensorflow==2.4.1
  • turicreate==6.4.1

After the preprocessing stage I got the following error:

Parsing completed. Parsed 100 lines in 0.006422 secs.
------------------------------------------------------
Inferred types from first 100 line(s) of file as
column_type_hints=[str,int,int,str,str,int,str]
If parsing fails due to incorrect types, you can correct
the inferred type list above and pass it to read_csv in
the column_type_hints argument
------------------------------------------------------
Finished parsing file /home/ananasn/code/yaroslav/sfx/ESC-50-master/meta/esc50.csv
Parsing completed. Parsed 2000 lines in 0.005047 secs.
2021-04-07 05:24:07.811986: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2021-04-07 05:24:09.405138: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2021-04-07 05:24:09.405193: W tensorflow/stream_executor/cuda/cuda_driver.cc:326] failed call to cuInit: UNKNOWN ERROR (303)
Creating a validation set from 5 percent of training data. This may take a while.
        You can set ``validation_set=None`` to disable validation tracking.

Preprocessing audio data -
Preprocessed 117 of 304 examples
Preprocessed 241 of 304 examples
Preprocessed 304 of 304 examples

Traceback (most recent call last):
  File "create_model.py", line 20, in <module>
    model = tc.sound_classifier.create(train_set, target='category', feature='audio')
  File "/home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/turicreate/toolkits/sound_classifier/sound_classifier.py", line 371, in create
    train_deep_features = get_deep_features(dataset[feature], verbose=verbose)
  File "/home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/turicreate/toolkits/sound_classifier/sound_classifier.py", line 232, in get_deep_features
    return feature_extractor.get_deep_features(audio_data, verbose=verbose)
  File "/home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/turicreate/toolkits/sound_classifier/_audio_feature_extractor.py", line 166, in get_deep_features
    deep_features = self._extract_features(preprocessed_data, verbose)
  File "/home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/turicreate/toolkits/sound_classifier/_audio_feature_extractor.py", line 119, in _extract_features
    y = self.vggish_model.predict([[cur_example]])
  File "/home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py", line 1629, in predict
    tmp_batch_outputs = self.predict_function(iterator)
  File "/home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 828, in __call__
    result = self._call(*args, **kwds)
  File "/home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 871, in _call
    self._initialize(args, kwds, add_initializers_to=initializers)
  File "/home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 725, in _initialize
    self._stateful_fn._get_concrete_function_internal_garbage_collected(  # pylint: disable=protected-access
  File "/home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 2969, in _get_concrete_function_internal_garbage_collected
    graph_function, _ = self._maybe_define_function(args, kwargs)
  File "/home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 3361, in _maybe_define_function
    graph_function = self._create_graph_function(args, kwargs)
  File "/home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 3196, in _create_graph_function
    func_graph_module.func_graph_from_py_func(
  File "/home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/framework/func_graph.py", line 990, in func_graph_from_py_func
    func_outputs = python_func(*func_args, **func_kwargs)
  File "/home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 634, in wrapped_fn
    out = weak_wrapped_fn().__wrapped__(*args, **kwds)
  File "/home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/framework/func_graph.py", line 977, in wrapper
    raise e.ag_error_metadata.to_exception(e)
ValueError: in user code:

    /home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:1478 predict_function  *
        return step_function(self, iterator)
    /home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:1468 step_function  **
        outputs = model.distribute_strategy.run(run_step, args=(data,))
    /home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/distribute/distribute_lib.py:1259 run
        return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)
    /home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/distribute/distribute_lib.py:2730 call_for_each_replica
        return self._call_for_each_replica(fn, args, kwargs)
    /home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/distribute/distribute_lib.py:3417 _call_for_each_replica
        return fn(*args, **kwargs)
    /home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:1461 run_step  **
        outputs = model.predict_step(data)
    /home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:1434 predict_step
        return self(x, training=False)
    /home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:998 __call__
        input_spec.assert_input_compatibility(self.input_spec, inputs, self.name)
    /home/ananasn/code/yaroslav/sfx/venv/lib/python3.8/site-packages/tensorflow/python/keras/engine/input_spec.py:271 assert_input_compatibility
        raise ValueError('Input ' + str(input_index) +

 ValueError: Input 0 is incompatible with layer vggish: expected shape=(None, 96, 64, 1), found shape=(32, 64, 1)

ananasn avatar Apr 07 '21 02:04 ananasn

I'm not able to replicate this issue. I can successfully run the Introductory Example for the Sound Classifier using your versions of TuriCreate and TensorFlow.

A few questions: 1 - What operating system are you using? 2 - What version of Python are you using? 3 - Did this issue happen once or does it happen every time you try running the code?

TobyRoseman avatar Apr 07 '21 23:04 TobyRoseman

Thanks for your quick response!

  1. Ubuntu 20.04 (via WSL Windows 10)
  2. Python 3.8.5
  3. Every time running code

Also there is my pip freeze result:

absl-py==0.12.0
appdirs==1.4.3
astunparse==1.6.3
attr==0.3.1
attrs==20.3.0
CacheControl==0.12.6
cachetools==4.2.1
certifi==2019.11.28
chardet==3.0.4
colorama==0.4.3
contextlib2==0.6.0
coremltools==4.0b3
decorator==5.0.5
distlib==0.3.0
distro==1.4.0
flatbuffers==1.12
gast==0.3.3
google-auth==1.28.0
google-auth-oauthlib==0.4.4
google-pasta==0.2.0
grpcio==1.32.0
h5py==2.10.0
html5lib==1.0.1
idna==2.8
ipaddr==2.2.0
Keras-Preprocessing==1.1.2
llvmlite==0.33.0
lockfile==0.12.2
Markdown==3.3.4
mpmath==1.2.1
msgpack==0.6.2
numba==0.50.1
numpy==1.19.5
oauthlib==3.1.0
opt-einsum==3.3.0
packaging==20.3
pandas==1.2.3
pep517==0.8.2
Pillow==8.2.0
prettytable==0.7.2
progress==1.5
protobuf==3.15.7
pyasn1==0.4.8
pyasn1-modules==0.2.8
pyparsing==2.4.6
python-dateutil==2.8.1
pytoml==0.1.21
pytz==2021.1
requests==2.22.0
requests-oauthlib==1.3.0
resampy==0.2.1
retrying==1.3.3
rsa==4.7.2
scipy==1.4.1
six==1.15.0
sympy==1.7.1
tensorboard==2.4.1
tensorboard-plugin-wit==1.8.0
tensorflow==2.4.1
tensorflow-estimator==2.4.0
termcolor==1.1.0
tqdm==4.59.0
turicreate==6.4.1
typing-extensions==3.7.4.3
urllib3==1.25.8
webencodings==0.5.1
Werkzeug==1.0.1
wrapt==1.12.1

ananasn avatar Apr 08 '21 00:04 ananasn

This is a TensorFlow issue. On Linux (and older versions of macOS) TuriCreate uses TensorFlow to generate the deep feature.

To reproduce this issue without TuriCreate, first download the keras model. Then run:

from tensorflow import keras
import numpy as np

m = keras.models.load_model('./VGGishFeatureEmbedding-v1.h5')
x = np.ones((96, 64, 1))
m.predict([[x]])

The above code work with TensorFlow version 2.1.3 but stops working with 2.2.0.

@ananasn - I recommend creating a TensorFlow issue with the above information. Please share a link to that issue here. I'll leave this issue open.

TobyRoseman avatar Apr 12 '21 19:04 TobyRoseman