ryanwongsa / kaggle-birdsong-recognition

1st Place solution to the Cornell Birdcall Identification competition.
https://www.kaggle.com/c/birdsong-recognition
MIT License
150 stars 30 forks source link

Module import issues? #3

Closed ghost closed 3 years ago

ghost commented 3 years ago

When I try to run python sed_train.py --config "config_params.example_config" I get the response:

Traceback (most recent call last):
  File "src/sed_train.py", line 2, in <module>
    from engine.sed_engine import SedEngine
ImportError: No module named engine.sed_engine

I tried to resolve this by adding __init__.py files to the folders but am now running into the following issue:

Traceback (most recent call last):
  File "src/sed_train.py", line 2, in <module>
    from engine.sed_engine import SedEngine
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/src/engine/sed_engine.py", line 132
    from logger.print.print_logger import PrintLogger
                    ^
SyntaxError: invalid syntax

Which is curious! Any idea whats going on here?

ryanwongsa commented 3 years ago

Are you running it while in the src/ folder, as the above error doesn’t match the command you are giving it. If you were running it while in the base folder, and using the following command:

python src/sed_train.py --config "config_params.example_config"

then I would expect to see your first error.

Also you should be using python 3, as I haven’t tested it on python 2.

ghost commented 3 years ago

Edited: Great -- I'm using Python 3 - is any version okay? I'm using Python 3.9.4.

I'm coming on a different error when I run that command from the src folder.

NVIDIA Apex not found, not using mixed precision
2021-06-18 09:27:09,461 ignite.distributed.launcher.Parallel INFO: - Run '<function run at 0x100d068b0>' in 1 processes
Traceback (most recent call last):
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/src/sed_train.py", line 26, in <module>
    main(hyperparams)
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/src/sed_train.py", line 14, in main
    parallel.run(run, hyperparams)
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/venv/lib/python3.9/site-packages/ignite/distributed/launcher.py", line 248, in run
    func(local_rank, *args, **kwargs)
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/src/sed_train.py", line 9, in run
    pe = SedEngine(local_rank, config)
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/src/engine/sed_engine.py", line 14, in __init__
    super().__init__(local_rank, hparams)
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/src/engine/base/base_engine.py", line 40, in __init__
    self._init_augmentation()
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/src/engine/sed_engine.py", line 205, in _init_augmentation
    from augmentations.sed_background_augment import get_transforms
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/src/augmentations/sed_background_augment.py", line 4, in <module>
    import librosa
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/venv/lib/python3.9/site-packages/librosa/__init__.py", line 12, in <module>
    from . import core
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/venv/lib/python3.9/site-packages/librosa/core/__init__.py", line 125, in <module>
    from .time_frequency import *  # pylint: disable=wildcard-import
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/venv/lib/python3.9/site-packages/librosa/core/time_frequency.py", line 11, in <module>
    from ..util.exceptions import ParameterError
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/venv/lib/python3.9/site-packages/librosa/util/__init__.py", line 77, in <module>
    from .utils import *  # pylint: disable=wildcard-import
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/venv/lib/python3.9/site-packages/librosa/util/utils.py", line 15, in <module>
    from .decorators import deprecated
  File "/Users/ada/Desktop/Developer/projects/kaggle-birdsong-recognition/venv/lib/python3.9/site-packages/librosa/util/decorators.py", line 9, in <module>
    from numba.decorators import jit as optional_jit
ModuleNotFoundError: No module named 'numba.decorators'
ryanwongsa commented 3 years ago

It looks like a dependency issue. I haven’t tested it with python 3.9 but if you check one of the example Kaggle notebooks and then check versions of pip packages then you might be able to resolve it. Also if you search the error you might find some other people have had the above issue with librosa and solutions to resolve it.

ghost commented 3 years ago

Just to follow up:

I got things kind of working by:

Now I'm running into the following error:

File "/(blahblah)/projects/kaggle-birdsong-recognition/.venv/lib/python3.7/site-packages/audiomentations/augmentations/transforms.py", line 439, in __init__
    assert len(self.sound_file_paths) > 0
AssertionError

This looks like an error with the audiomentations dependency?

When you say: "store the training data in /data", there are several files in that package from kaggle. Are you referring to just the train_audio folder?

Thanks for being available and making a cool tool.

ryanwongsa commented 3 years ago

I think that error is because you don't have any files in the config for the augmentation.

        self.bckgrd_aug_dir = "/pinknoise"
        self.secondary_bckgrd_aug_dir = "/pinknoise"

So the /pinknoise folder needs to be changed to your directory that contains the pink noise. As for the /data folder, It should be the folder containing the audio files that are separated into folders with the bird id as the name. But in the Kaggle notebook version I had it as a dictionary because the resampled data was created by a user who had to separate the audios into multiple datasets because of storage limitations.