Code Monkey home page Code Monkey logo

Comments (10)

dbogdanov avatar dbogdanov commented on July 22, 2024 1

@5pacedo9 You need to downsample the audio to 16000 before it is fed into the TensorflowPredictEffnetDiscogs algorithm, otherwise its internal frame and hop size to compute model input representation wouldn't match what the model expects. Therefore you should use MonoLoader with sampleRate=16000.

Closing this issue as the initial question is resolved. We rely on Homebrew for all Essentia dependencies, and it supports only the latest three MacOS versions. If you have further questions about the model, feel free to open a separate issue.

from essentia.

5pacedo9 avatar 5pacedo9 commented on July 22, 2024

I guess it's because I'm using Big Sur, and I also brewed essentia --with-tensorflow so I decided to replaced the essentia(2.1b6.dev1110) install by pip with the brewed one(HEAD-b584c9b),
I moved/opt/homebrew/Cellar/essentia/HEAD-b584c9b/lib/python3.9/site-packages/essentia to /Users/5pacedo9/anaconda3/envs/py311/lib/python3.11/site-packages/essentia/

from essentia.

5pacedo9 avatar 5pacedo9 commented on July 22, 2024

And the error was gone but another come.

Traceback (most recent call last):
  File "/Volumes/A/PycharmProjects/essentia_test/main.py", line 1, in <module>
    from essentia.standard import MonoLoader, TensorflowPredictEffnetDiscogs, TensorflowPredict2D
  File "/Users/5pacedo9/anaconda3/envs/py311/lib/python3.11/site-packages/essentia/__init__.py", line 1, in <module>
    from . import _essentia
ImportError: cannot import name '_essentia' from partially initialized module 'essentia' (most likely due to a circular import) (/Users/5pacedo9/anaconda3/envs/py311/lib/python3.11/site-packages/essentia/__init__.py)

It seems that brewed one was built on python3.9

from essentia.

5pacedo9 avatar 5pacedo9 commented on July 22, 2024

I switched to python3.9 and replaced essentia with brewed one and finally the IMPORT ERROR was gone.
But I met runtime error which I don't know how to solve.

[   INFO   ] TensorflowPredict: Successfully loaded graph file: `/Volumes/A/PycharmProjects/essentia_test/genre_discogs400-discogs-effnet-1.pb`
Traceback (most recent call last):
  File "/Volumes/A/PycharmProjects/essentia_test/main.py", line 5, in <module>
    embedding_model = TensorflowPredictEffnetDiscogs(graphFilename="/Volumes/A/PycharmProjects/essentia_test/genre_discogs400-discogs-effnet-1.pb", output="PartitionedCall:1")
  File "/Users/5pacedo9/anaconda3/envs/python39/lib/python3.9/site-packages/essentia/standard.py", line 44, in __init__
    self.configure(**kwargs)
  File "/Users/5pacedo9/anaconda3/envs/python39/lib/python3.9/site-packages/essentia/standard.py", line 64, in configure
    self.__configure__(**kwargs)
RuntimeError: Error while configuring TensorflowPredictEffnetDiscogs: TensorflowPredict: 'serving_default_melspectrogram' is not a valid node name of this graph.
TensorflowPredict: Available node names are:
Const, Const_1, NoOp, Const_2, serving_default_model_Placeholder, PartitionedCall, saver_filename, StatefulPartitionedCall, StatefulPartitionedCall_1.

Reconfigure this algorithm with valid node names as inputs and outputs before starting the processing.

code in main.py remains unchanged.

Please forgive me if I made some ridiculous mistakes, I'm totally new to python and tensorflow.

from essentia.

5pacedo9 avatar 5pacedo9 commented on July 22, 2024

I've found that I put the wrong .pb file in TensorflowPredictEffnetDiscogs()
and now the code is like

from essentia.standard import MonoLoader, TensorflowPredictEffnetDiscogs, TensorflowPredict2D

if __name__ == '__main__':
    audio = MonoLoader(filename="/Volumes/B/DJ/Trance/Dragon (Original Mix) - Shogun,Adara.mp3", sampleRate=44100, resampleQuality=4)()
    embedding_model = TensorflowPredictEffnetDiscogs(graphFilename="/Volumes/A/PycharmProjects/essentia_test/discogs-effnet-bs64-1.pb", output="PartitionedCall:1")
    embeddings = embedding_model(audio)

    model = TensorflowPredict2D(graphFilename="/Volumes/A/PycharmProjects/essentia_test/genre_discogs400-discogs-effnet-1.pb", input="serving_default_model_Placeholder", output="PartitionedCall:0")
    predictions = model(embeddings)

and the output:

[   INFO   ] TensorflowPredict: Successfully loaded graph file: `/Volumes/A/PycharmProjects/essentia_test/discogs-effnet-bs64-1.pb`
2024-01-25 17:33:17.032197: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:388] MLIR V1 optimization pass is not enabled
[   INFO   ] TensorflowPredict: Successfully loaded graph file: `/Volumes/A/PycharmProjects/essentia_test/genre_discogs400-discogs-effnet-1.pb`
[   INFO   ] TensorflowPredict: Successfully loaded graph file: `/Volumes/A/PycharmProjects/essentia_test/genre_discogs400-discogs-effnet-1.pb`

Did I run it successfully? And how to transform the predictions into the predicted genres that I want?

from essentia.

dbogdanov avatar dbogdanov commented on July 22, 2024

Hi @5pacedo9 , it ran successfully.
You can consult the list of the predicted genres in the model's metadata JSON file.

from essentia.

5pacedo9 avatar 5pacedo9 commented on July 22, 2024

Thank you, @dbogdanov , do you know how to get predicted genres by consulting the json file?
predictions is a numpy.ndarray in shape ["batch_size",400], and I don't know how to convert these data with json file into genres.

from essentia.

dbogdanov avatar dbogdanov commented on July 22, 2024

Here is an example of loading the JSON metadata file and matching activations to class labels.

from essentia.

5pacedo9 avatar 5pacedo9 commented on July 22, 2024

Thank you, @dbogdanov , I got the predicted genres and output the one with highest possibility, but it seems that all the genres are not correct, the genre of these inputted songs is Trance, but I get either vaporware or experimental. And I realize it might be caused by sample rate, in my code:audio = MonoLoader(filename=filePath, sampleRate=44100, resampleQuality=4)(), when I changed sampleRate to 16000, I finally got the right genre Trance. This seems weird because all of the tested songs' sample rate is 44100 but not 16000.

from essentia.

5pacedo9 avatar 5pacedo9 commented on July 22, 2024

Thanks for your help.

from essentia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.