Merge branch 'master' of ssh://invnuc/~/Public/Repos/speech_scoring
commit
1928fce4e8
|
|
@ -143,3 +143,5 @@ inputs/audio*
|
|||
logs/*
|
||||
models/*
|
||||
*.pkl
|
||||
temp/*
|
||||
trained/*
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ def read_siamese_tfrecords_generator(audio_group='audio',batch_size=32,test_size
|
|||
(n_spec,n_features,n_records) = pickle.load(open(const_file,'rb'))
|
||||
|
||||
def copy_read_consts(dest_dir):
|
||||
shutil.copy2(const_file,dest_dir)
|
||||
shutil.copy2(const_file,dest_dir+'/constants.pkl')
|
||||
return (n_spec,n_features,n_records)
|
||||
# @threadsafe_iter
|
||||
def record_generator():
|
||||
|
|
@ -210,15 +210,14 @@ def record_generator_count(records_file):
|
|||
record_iterator = tf.python_io.tf_record_iterator(path=records_file)
|
||||
count,spec_n = 0,0
|
||||
for i in record_iterator:
|
||||
example = tf.train.Example()
|
||||
example.ParseFromString(i)
|
||||
spec_n1 = example.features.feature['spec_n1'].int64_list.value[0]
|
||||
spec_n2 = example.features.feature['spec_n2'].int64_list.value[0]
|
||||
spec_n = max([spec_n,spec_n1,spec_n2])
|
||||
import pdb; pdb.set_trace()
|
||||
# example = tf.train.Example()
|
||||
# example.ParseFromString(i)
|
||||
# spec_n1 = example.features.feature['spec_n1'].int64_list.value[0]
|
||||
# spec_n2 = example.features.feature['spec_n2'].int64_list.value[0]
|
||||
# spec_n = max([spec_n,spec_n1,spec_n2])
|
||||
count+=1
|
||||
record_iterator = tf.python_io.tf_record_iterator(path=records_file)
|
||||
return record_iterator,count,spec_n
|
||||
return record_iterator,count #,spec_n
|
||||
|
||||
def fix_csv(audio_group='audio'):
|
||||
audio_csv_lines = open('./outputs/' + audio_group + '.csv','r').readlines()
|
||||
|
|
@ -260,8 +259,8 @@ if __name__ == '__main__':
|
|||
# create_spectrogram_tfrecords('story_all',sample_count=25)
|
||||
# fix_csv('story_words_test')
|
||||
#fix_csv('audio')
|
||||
# create_spectrogram_tfrecords('story_words_test',sample_count=100,train_test_ratio=0.1)
|
||||
record_generator_count()
|
||||
create_spectrogram_tfrecords('story_words_test',sample_count=10,train_test_ratio=0.1)
|
||||
#record_generator_count()
|
||||
# create_spectrogram_tfrecords('audio',sample_count=50)
|
||||
# read_siamese_tfrecords_generator('audio')
|
||||
# padd_zeros_siamese_tfrecords('audio')
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ def train_siamese(audio_group = 'audio'):
|
|||
, epochs=1000
|
||||
, steps_per_epoch=epoch_n_steps
|
||||
, validation_data=([te_pairs[:, 0], te_pairs[:, 1]], te_y)
|
||||
, max_queue_size=32
|
||||
, max_queue_size=8
|
||||
, callbacks=[tb_cb, cp_cb])
|
||||
model.save(model_dir+'/siamese_speech_model-final.h5')
|
||||
|
||||
|
|
@ -125,4 +125,4 @@ def train_siamese(audio_group = 'audio'):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
train_siamese('story_phrases')
|
||||
train_siamese('story_words_test')
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ def test_with(audio_group):
|
|||
def evaluate_siamese(records_file,audio_group='audio',weights = 'siamese_speech_model-final.h5'):
|
||||
# audio_group='audio';model_file = 'siamese_speech_model-305-epoch-0.20-acc.h5'
|
||||
# records_file = os.path.join('./outputs',eval_group+'.train.tfrecords')
|
||||
const_file = os.path.join('./models/'+audio_group+'/',audio_group+'.constants')
|
||||
const_file = os.path.join('./models/'+audio_group+'/','constants.pkl')
|
||||
arch_file='./models/'+audio_group+'/siamese_speech_model_arch.yaml'
|
||||
weight_file='./models/'+audio_group+'/'+weights
|
||||
(n_spec,n_features,n_records) = pickle.load(open(const_file,'rb'))
|
||||
|
|
@ -41,7 +41,6 @@ def evaluate_siamese(records_file,audio_group='audio',weights = 'siamese_speech_
|
|||
total,same_success,diff_success,skipped,same_failed,diff_failed = 0,0,0,0,0,0
|
||||
all_results = []
|
||||
for (i,string_record) in tqdm(enumerate(record_iterator),total=records_count):
|
||||
# string_record = next(record_iterator)
|
||||
total+=1
|
||||
example = tf.train.Example()
|
||||
example.ParseFromString(string_record)
|
||||
|
|
@ -178,7 +177,7 @@ def visualize_results(audio_group='audio'):
|
|||
if __name__ == '__main__':
|
||||
# evaluate_siamese('./outputs/story_words_test.train.tfrecords',audio_group='story_words.gpu',weights ='siamese_speech_model-58-epoch-0.00-acc.h5')
|
||||
# evaluate_siamese('./outputs/story_words.test.tfrecords',audio_group='story_words',weights ='siamese_speech_model-675-epoch-0.00-acc.h5')
|
||||
evaluate_siamese('./outputs/story_words_test.train.tfrecords',audio_group='story_words.gpu',weights ='siamese_speech_model-58-epoch-0.00-acc.h5')
|
||||
evaluate_siamese('./outputs/story_words_test.train.tfrecords',audio_group='story_words_test.10',weights ='siamese_speech_model-891-epoch-0.02-acc.h5')
|
||||
# play_results('story_words')
|
||||
#inspect_tfrecord('./outputs/story_phrases.test.tfrecords',audio_group='story_phrases')
|
||||
# visualize_results('story_words.gpu')
|
||||
|
|
|
|||
Loading…
Reference in New Issue