예제 #1
0
    def logger(self):
        logger = logging.getLogger(__name__)
        if not logger.handlers:
            from dcase_util.utils import setup_logging
            setup_logging()

        return logger
예제 #2
0
파일: mixins.py 프로젝트: dby124/dcase_util
    def logger(self):
        """Logger instance"""

        logger = logging.getLogger(__name__)
        if not logger.handlers:
            setup_logging()
        return logger
예제 #3
0
def feature_extractor_factory(feature_extractor_label, **kwargs):
    """Function to get correct feature extractor class instance based on extractor label or class name.

    Parameters
    ----------
    feature_extractor_label : str
        Class name or extractor label

    Raises
    ------
    NameError
        Class does not exists

    Returns
    -------
    Feature extractor class instance

    """

    try:
        feature_extractor_class = None

        # Get all classes inherited from FeatureExtractor
        class_list = get_class_inheritors(FeatureExtractor)

        # Search correct feature extractor
        for item in class_list:
            if str(item.__name__) == feature_extractor_label:
                feature_extractor_class = getattr(
                    importlib.import_module(str(item.__module__)),
                    feature_extractor_label)
                break

            elif hasattr(
                    item, 'label'
            ) and item.label == feature_extractor_label and item.__name__.endswith(
                    'Extractor'):
                feature_extractor_class = getattr(
                    importlib.import_module(str(item.__module__)),
                    item.__name__)
                break

        # Valid feature extractor class not found, raise error
        if not feature_extractor_class:
            raise AttributeError

    except AttributeError:

        message = 'Invalid FeatureExtractor class name or extractor label given [{label}].'.format(
            label=feature_extractor_label)
        logger = logging.getLogger(__name__)
        if not logger.handlers:
            setup_logging()

        logger.exception(message)
        raise AttributeError(message)

    return feature_extractor_class(**dict(kwargs))
예제 #4
0
파일: mixins.py 프로젝트: dby124/dcase_util
    def logger(self):
        logger = logging.getLogger(__name__)
        if not logger.handlers:
            setup_logging()

        return logger
예제 #5
0
파일: utils.py 프로젝트: mic2zar/dcase_util
 def logger():
     logger_instance = logging.getLogger(__name__)
     if not logger_instance.handlers:
         setup_logging()
     return logger_instance
예제 #6
0
class MyLogger(object):
    def debug(self, msg):
        pass

    def warning(self, msg):
        pass

    def error(self, msg):
        pass


if __name__ == "__main__":
    from dcase_util.ui.ui import FancyLogger
    from dcase_util.utils import setup_logging

    setup_logging(logging_file='download_data.log')
    log = FancyLogger()

    log.title("Download_data")
    log.info(
        "Once database is downloaded, do not forget to check your missing_files"
    )

    # Modify it with the number of process you want, but be careful, youtube can block you if you put too many.
    N_JOBS = 3

    # Only useful when multiprocessing,
    # if chunk_size is high, download is faster. Be careful, progress bar only update after each chunk.
    CHUNK_SIZE = 10

    log.line("Test data")
예제 #7
0
# -*- coding: utf-8 -*-
#########################################################################
# Initial software
# Copyright Nicolas Turpault, Romain Serizel, Hamid Eghbal-zadeh, Ankit Parag Shah, 2018, v1.0
# This software is distributed under the terms of the License MIT
#########################################################################

import pandas as pd
import glob
import os
import argparse
from dcase_util.ui.ui import FancyLogger
from dcase_util.utils import setup_logging

setup_logging(logging_file='check_data.log')
log = FancyLogger()


# This function is not used in the baseline but can be used to check if your audio folders correspond to your metadata
def check_audio_vs_meta(csv_file, audio_dir, write=False):
    """ Check AudioSet filenames contained in csv_file are all present in the resulting audio directory

        Parameters
        ----------

        csv_file : str, filename of a csv file which contains a column "filename" listing AudioSet filenames downloaded

        audio_dir : str, audio directory which contains downloaded files

        write : bool, Write the missing files into a csv file or not.