Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion model/lasagne_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion model/learning_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ def dynamicLearningRate(mode, epoch):

for epoch in range(1, cfg.EPOCHS + 1):

print dynamicLearningRate('cosine', epoch)
print(dynamicLearningRate('cosine', epoch))
14 changes: 7 additions & 7 deletions sort_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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__':
Expand Down
2 changes: 1 addition & 1 deletion spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
2 changes: 1 addition & 1 deletion submission_monophone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion submission_soundscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions utils/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import librosa
from builtins import range

import cv2

Expand All @@ -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?
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion utils/batch_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import config as cfg
from utils import image
from builtins import range

RANDOM = cfg.getRandomState()

Expand Down Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions utils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 += ' '
Expand Down