Example #1
0
    -r --rerun_statistics   Override to model_fit statistics lock [default: False]
'''

from docopt import docopt
from modules.spect_gen import spect_gen
from modules.view import view
from modules.model_fit import model_fit
from modules.predict import predict
from modules.utils import generate_config
from modules.init import init

# From the docstring, generate the arguments dictionary
arguments = docopt(__doc__, version='opensoundscape.py version 0.0.1')

# Get the default config variables
config = generate_config("config/opensoundscape.ini", arguments["--ini"])

# Initialize empty string for arguments['<image>'] (not supported by docopt)
if not arguments['<image>']:
    arguments['<image>'] = ''

if arguments['spect_gen']:
    # Pass the configuration to spect_gen
    spect_gen(config)

elif arguments['view']:
    # Preprocess the file with the defaults
    # -> optionally write image to a file
    view(arguments['<label>'], arguments['<image>'], arguments['--segments'],
         config)
# Need some functions from our module
import sys
script_dir = sys.path[0]
sys.path.insert(0, f"{script_dir}/..")

from modules.utils import generate_config, return_cpu_count
from modules.db_utils import cursor_item_to_stats
from modules.db_utils import return_cursor

# From the docstring, generate the arguments dictionary
arguments = docopt(__doc__,
                   version='find_important_templates.py version 0.0.1')

# Generate the config instance
config = generate_config('config/opensoundscape.ini', arguments['--ini'])

# Generate list of files which identify <label>
labels_df = pd.read_csv(
    f"{config['general']['data_dir']}/{config['general']['train_file']}",
    index_col="Filename")
labels_df = labels_df.fillna(0).astype(int)

# Downsample to particular species
species = arguments["<label>"]

# Identify files with and without bird
species_found = labels_df[species][labels_df[species] == 1]
species_not_found = labels_df[species][labels_df[species] == 0]

# Generate list of tuples with identifying features for templates
def ini_test_change():
    return generate_config('../config/opensoundscape.ini',
                           'ini_test_change.ini')