essentia
essentia copied to clipboard
iOS build broken (Tensorflow dependency)
Building with python3 waf configure --cross-compile-ios --lightweight= --fft=ACCELERATE --build-static --ignore-algos=NNLSChroma
I needed to comment out two sections in types.h
;
- Relating to string comparison;
- I needed to comment out the function
case_insensitive_str_cmp()
- this may be related to https://stackoverflow.com/questions/22386882/why-have-unary-function-binary-function-been-removed-from-c11
- I needed to comment out the function
- Relating to Tensor;
- I needed to comment out:
-
#include <unsupported/Eigen/CXX11/Tensor>
- The 6 or so Tensor types (starting from
Alias for Eigen::Tensor.
).
-
- I needed to comment out:
This is despite Tensor apparently being ignored; the build log gives:
- Essentia is configured without Tensorflow.
The following algorithms will be ignored: ['TensorflowPredict', 'TensorflowPredictMusiCNN',
'TensorflowPredictVGGish', 'TensorflowPredictTempoCNN', 'TensorflowPredictCREPE',
'PitchCREPE', 'TempoCNN', 'TensorflowPredictEffnetDiscogs', 'TensorflowPredict2D', 'TensorflowPredictFSDSINet']
Is there any fix already present that I simply need to enable?
I'm building on MacOS Ventura 13.4, with Xcode 15.0 beta 2.
Update: as the Stackoverflow post hints at, switching the C++ dialect to gnu++14 (in Xcode) solves the problem for the string comparison function.
hi @LDMFD, right, the Tensorflow-related algorithms are ignored by default, but we don't have a mechanism to prevent creating the Tensor types.
I can see that similar problems occur in OpenCV, and they now support deactivating the Eigen Tensors.
We could be interested in doing the same.
Hi @palonso thank you for the feedback. I hit this problem again after including essentiamath.h
. What is the correct fix for iOS builds?
I built with --with-tensorflow
but looking at the missing symbols, it seems Essentia depends on the full Tensorflow library, so:
- Are the Tensor-based features of Essentia available for mobile?
- Regardless of Tensorflow, is there a known build working for iOS? (if so, what am I missing)
I am looking for pitch detection primarily.
@LDMFD,
Essentia only depends on TensorFlow when using the --with-tensorflow
flag.
The purpose of TensorFlow is to use our Essentia Models, so for your use case, you can build Essentia without the flag.
Since tensor-based methods are only required when using these models, we could have a directive WITH_TENSORFLOW
to skip tensor-based auxiliary methods and types when TensorFlow is not required.
For now, you can just comment out these methods in essentiamath.h
and the types.
Appreciate the pointer - will give this a try.
I'm following up here in hopes this will be useful for others. From what I can tell, Essentia with tensorflow (needed for TemopCNN) is simply incompatible with iOS. TensorFlowLite (the only supported target for iOS), has a different set of interfaces to what the TempoCNN components in Essentia use. Including the TensorFlow header path in an XCode project results in undefined symbol compiler errors.
_TF_AllocateTensor, referenced from: essentia::standard::TensorflowPredict::configure() in libessentia.a[arm64]167 . . .
It would have been useful to know about this incompatibility before wasting a day trying to make it work. Hopefully this will be useful for others.
@ashayk We apologize for any confusion. Unfortunately, adding TensorFlowLite support is out of scope at the moment. We added a clarification to the FAQ (4c48bb1cabfd2f73f4555065806df67922c39ac0).