trainer = Trainer(args, args_subset, args_dict_update) trainer.sample(exp_num) ## SAMPLE ## ----------------------------- ## Sample Prep. del trainer gc.collect() print('Loading the best model and running the sample loop') args_dict_update = { 'render': args.render, 'window_hop': 0, 'sample_all_styles': 0 } ## Sample trainer = Trainer(args, args_subset, args_dict_update) trainer.sample(exp_num) ## Finish trainer.finish_exp() ## Print Experiment No. print('\nExperiment Number: {}'.format(args.exp)) if __name__ == '__main__': argparseNloop(loop)
## Sample print('Loading the best model and running the sample loop') args.__dict__.update({ 'load': book.name(book.weights_ext[0], book.weights_ext[1], args.save_dir) }) sample(args, exp_num, data) ## Render (on a cpu only node) # feats_kind_dict = {'rifke':'fke'} # print('Rendering') # render = Slurm('render', slurm_kwargs={'partition':'cpu_long', 'time':'10-00:00', 'n':10}) # python_cmd = ['source activate torch', # 'python render.py -dataset {} -load {} -feats_kind {} -render_list {}'.format( # args.dataset, # args.load, # feats_kind_dict[args.feats_kind], # args.render_list)] # render.run('\n'.join(python_cmd)) ## Render new sentences print('Rendering New Sentences') render_new_sentences(args, exp_num, data) # End Log book._stop_log() if __name__ == '__main__': argparseNloop(train)
kwargs_dict.update({'h1':'{}'.format(path2videos)}) temp_filename = next(tempfile._get_candidate_names()) get_html_snippet('grid.html', 'templates/{}.html'.format(temp_filename), kwargs_dict) file_list.append(temp_filename) kwargs_dict = {'filenames':['{}.html'.format(file) for file in file_list]} get_html_snippet('index.html', '{}.html'.format(temp_filename), kwargs_dict) temp_srcs = ['htmlUtils/app/templates/{}.html'.format(file) for file in file_list] src = 'htmlUtils/app/{}.html'.format(temp_filename) dest = os.path.join(path2videos, '{}.html'.format(outfile)) shutil.move(src, dest) for temp_src in temp_srcs: os.remove(temp_src) def makeHTMLfile_loop(args, exp_num): assert args.load, 'Load file must be provided' assert os.path.exists(args.load), 'Load file must exist' args_subset = ['exp', 'cpk', 'speaker', 'model'] book = BookKeeper(args, args_subset, args_dict_update={'render':args.render}, tensorboard=args.tb) args = book.args dir_name = book.name.dir(args.save_dir) makeHTMLfile(dir_name, idxs=args.render, outfile='videos') makeHTMLfile(dir_name, idxs=4, outfile='videos_subset') if __name__ == '__main__': argparseNloop(makeHTMLfile_loop)
num_iter=500) loss = criterion(y_cap, y) for i_loss in internal_losses: loss += i_loss running_loss += loss.item() * batch_size running_count += batch_size if count >= 0 and args.debug: ## debugging by overfitting break return running_loss / running_count train_loss = loop(model, data, train, pre, 'train') dev_loss = loop(model, data, dev, pre, 'dev') test_loss = loop(model, data, test, pre, 'test') ## update results but not save them book.update_res({'train': train_loss, 'dev': dev_loss, 'test': test_loss}) ## print results book.print_res(0, key_order=['train', 'dev', 'test'], exp=exp_num, lr=optim.param_groups[0]['lr']) if __name__ == '__main__': argparseNloop(sample)
save_animation(y_animates, intervals, dir_name, desc, data, start, subname=subname1, text=texts, output_modalities=output_modality, mask=mask) save_animation(y_animates_eval, intervals, dir_name, desc, data, start, subname=subname2, text=texts, output_modalities=output_modality, mask=mask) ## render html if set(keypoints_dirnames) - {'keypoints', 'keypoints_style'}: makeHTMLfile(dir_name, args.render, 'videos') makeHTMLfile(dir_name, 4, 'videos_subset') if __name__ == '__main__': argparseNloop(render)