ixobert / birds-generation

11 stars 1 forks source link

AttributeError: 'VQVAE' object has no attribute 'net' #10

Closed sammlapp closed 2 months ago

sammlapp commented 5 months ago

Ok, I got closer to successfully running the model but encountered a new error.

I'm not sure what the source of this error is, it seems the object being passed to interpolate doesn't contain the expected attribute .net but I don't know why.

in my call to generate_samples.py, is pointing the "model_path" argument to the downloaded .ckpt file correct ?

python birds-generation/src/generate_samples.py  --data_paths="./source_audio/*.wav" --out_folder="./generated_samples"  --model_path="/Users/SML161/song21_embedding_model/downloads/epoch=5-step=30005.ckpt"  --augmentations=interpolation --num_samples=3

0it [00:00, ?it/s]./source_audio/cswa_5.0s_10.0s.wav
Size: (1, 1, 128, 2097152)
./source_audio/cswa_10.0s_15.0s.wav
Size: (1, 1, 128, 2097152)
0it [00:33, ?it/s]
Traceback (most recent call last):
  File "birds-generation/src/generate_samples.py", line 253, in <module>
    main()
  File "birds-generation/src/generate_samples.py", line 242, in main
    func(
  File "birds-generation/src/generate_samples.py", line 158, in interpolation
    model.net, spectrogram, device=device
  File "/Users/SML161/miniconda3/envs/ecogen/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1269, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'VQVAE' object has no attribute 'net'
ixobert commented 5 months ago

@sammlapp, I have added a streamlit app to interact with the model,: link.

A better version of the code+docs is in the cooking...

sammlapp commented 5 months ago

Oh great, thanks. I might just wait for the updated version in that case. I really appreciate the effort to provide open-source tools/models and also your responsiveness to questions!

Cyh237 commented 3 months ago

i got the same problems when i want use the interpolation way to generate the audio. What can i do now for useing that now. D:\University\Software\Anaconda3\envs\ecogen39\python.exe D:\University\Code\Bird_sound_generation\birds-generation-master\test\generate_samples_audio.py 0it [00:00, ?it/s]data\test1.wav Size: (1, 1, 128, 128) data\test2.wav Size: (1, 1, 128, 128) 0it [00:02, ?it/s] Traceback (most recent call last): File "D:\University\Code\Bird_sound_generation\birds-generation-master\test\generate_samples_audio.py", line 214, in <module> main() File "D:\University\Code\Bird_sound_generation\birds-generation-master\test\generate_samples_audio.py", line 209, in main func(model=model, all_samples_paths=all_samples_paths, ratio=0.5, out_folder=args.out_folder, File "D:\University\Code\Bird_sound_generation\birds-generation-master\test\generate_samples_audio.py", line 131, in interpolation q_t, q_b, i_t, i_b = self.encode(model.net, spectrogram, device=device) File "D:\University\Software\Anaconda3\envs\ecogen39\lib\site-packages\torch\nn\modules\module.py", line 1269, in __getattr__ raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'VQVAE' object has no attribute 'net'

Cyh237 commented 3 months ago

i fine the reason is the Line:131 and 132, q_t, q_b, i_t, i_b = self.encode(model.net, spectrogram, device=device) q_t1, q_b1, i_t1, i_b1 = self.encode(model.net, spectrogram1, device=device) use the model.net, i delete the ".net", that the py can run, so is right?

masonyoungblood commented 2 months ago

I'm experiencing the same issue as @sammlapp - Are there any updates (besides the interactive app, which is a fantastic addition but does not appear to work for interpolation)?

masonyoungblood commented 2 months ago

I'm experiencing the same issue as @sammlapp - Are there any updates (besides the interactive app, which is a fantastic addition but does not appear to work for interpolation)?

I was able to temporarily solve the issue using @Cyh237 's solution! Replacing model.net with model everywhere in generate_samples.py.

ixobert commented 2 months ago

Code has been updated. Thank you @Cyh237 , @masonyoungblood