diff --git a/model/lasagne_net.py b/model/lasagne_net.py index 1d65b9e..611e4c4 100644 --- a/model/lasagne_net.py +++ b/model/lasagne_net.py @@ -26,7 +26,7 @@ from lasagne.layers import batch_norm as l_batch_norm import config as cfg -import lasagne_io as io +from model import lasagne_io as io from utils import log from lasagne import random as lasagne_random diff --git a/model/learning_rate.py b/model/learning_rate.py index 821c115..1535ac9 100644 --- a/model/learning_rate.py +++ b/model/learning_rate.py @@ -52,4 +52,4 @@ def dynamicLearningRate(mode, epoch): for epoch in range(1, cfg.EPOCHS + 1): - print dynamicLearningRate('cosine', epoch) + print(dynamicLearningRate('cosine', epoch)) diff --git a/sort_data.py b/sort_data.py index d9adb8c..2e259d3 100644 --- a/sort_data.py +++ b/sort_data.py @@ -20,12 +20,12 @@ def parseDataset(): # List of wav-files wav_path = os.path.join(cfg.TRAINSET_PATH, 'wav') wav_files = [f for f in sorted(os.listdir(wav_path))] - print 'DATASET CONTAINS', len(wav_files), 'WAV_FILES' + print('DATASET CONTAINS', len(wav_files), 'WAV_FILES') # List all xml-files xml_path = os.path.join(cfg.TRAINSET_PATH, 'xml') xml_files = [os.path.join(xml_path, f) for f in sorted(os.listdir(xml_path))] - print 'PARSING', len(xml_files), 'XML-FILES...' + print('PARSING', len(xml_files), 'XML-FILES...') # Open xml-files and extract metadata for i in range(len(xml_files)): @@ -56,21 +56,21 @@ def parseDataset(): # Status (parsing the files might take a while) if not i % 100: - print '\t', i, '/', len(xml_files) + print('\t', i, '/', len(xml_files)) - print '...DONE!', len(metadata), 'CLASSES IN DATASET' + print('...DONE!', len(metadata), 'CLASSES IN DATASET') return metadata #################### CREATE SPLITS ##################### def sortDataset(mdata): - print 'PARSING CLASSES...' + print('PARSING CLASSES...') # Parse classes for c in mdata: - print '\t', c + print('\t', c) # Determine size of val split (10% but at least 1 file) val = max(1, len(mdata[c]) * 0.1) @@ -107,7 +107,7 @@ def sortDataset(mdata): else: copyfile(os.path.join(cfg.TRAINSET_PATH, 'wav', f['filename']), os.path.join(t_path, f['filename'])) - print '...DONE!' + print('...DONE!') if __name__ == '__main__': diff --git a/spec.py b/spec.py index e60a5cb..bbcdc11 100644 --- a/spec.py +++ b/spec.py @@ -66,7 +66,7 @@ def parseDataset(): try: # Stats - print i + 1, '/', len(afiles), c, afiles[i], + print(i + 1, '/', len(afiles), c, afiles[i],) # Get specs and signal to noise ratios specs, noise = getSpecs(os.path.join(cfg.TRAINSET_PATH, 'train', c, afiles[i])) diff --git a/submission_monophone.py b/submission_monophone.py index 400845a..98a96e7 100644 --- a/submission_monophone.py +++ b/submission_monophone.py @@ -51,7 +51,7 @@ def getClassId(c): if c in LABELS: return CODES[LABELS.index(c)] else: - print 'MISSING CLASS:', c + print('MISSING CLASS:', c) return False def runTest(SNAPSHOTS, TEST): diff --git a/submission_soundscape.py b/submission_soundscape.py index 1eca368..8f405d5 100644 --- a/submission_soundscape.py +++ b/submission_soundscape.py @@ -61,7 +61,7 @@ def getClassId(c): if c in LABELS: return CODES[LABELS.index(c)] else: - print 'MISSING CLASS:', c + print('MISSING CLASS:', c) return False def getSpecBatches(split): diff --git a/utils/audio.py b/utils/audio.py index d54c35a..69093c0 100644 --- a/utils/audio.py +++ b/utils/audio.py @@ -2,6 +2,7 @@ import numpy as np import librosa +from builtins import range import cv2 @@ -20,7 +21,7 @@ def splitSignal(sig, rate, seconds, overlap, minlen): # Split signal with overlap sig_splits = [] - for i in xrange(0, len(sig), int((seconds - overlap) * rate)): + for i in range(0, len(sig), int((seconds - overlap) * rate)): split = sig[i:i + int(seconds * rate)] # End of signal? @@ -185,7 +186,7 @@ def specsFromFile(path, rate, seconds, overlap, minlen, shape, start=-1, end=-1, # Calculate and show noise measure noise = signal2noise(spec) - print noise + print(noise) # Show spec and wait for enter key cv2.imshow('SPEC', spec) diff --git a/utils/batch_generator.py b/utils/batch_generator.py index 03f0ac3..a2fc03d 100644 --- a/utils/batch_generator.py +++ b/utils/batch_generator.py @@ -9,6 +9,7 @@ import config as cfg from utils import image +from builtins import range RANDOM = cfg.getRandomState() @@ -41,7 +42,7 @@ def loadImageAndTarget(sample, augmentation): def getDatasetChunk(split): #get batch-sized chunks of image paths - for i in xrange(0, len(split), cfg.BATCH_SIZE): + for i in range(0, len(split), cfg.BATCH_SIZE): yield split[i:i+cfg.BATCH_SIZE] def getNextImageBatch(split, augmentation=True): diff --git a/utils/log.py b/utils/log.py index a8160ca..dd39f33 100644 --- a/utils/log.py +++ b/utils/log.py @@ -13,16 +13,16 @@ def show(s, new_line=False): if isinstance(s, (list, tuple)): for i in range(len(s)): - print s[i], + print(s[i]) log += str(s[i]) if i < len(s) - 1: log += ' ' else: - print s, + print(s) log += str(s) if new_line: - print '' + print('') log += '\n' else: log += ' '