# from LossFunctions import weight_loss_DC_3 as Loss1, weight_loss_MSE_3 as Loss2 from GenerateModels import ChimeraNet as GenerateModel tag = 'Feature{}Nsrc{}{}'.format(['Proposed', 'SpecSpat', 'SpecOnly'][args.featureFlag], args.srcNum, ['', 'Wei'][args.outputFlag]) print(tag) if args.save_dir is None: save_dir = './Models/{}'.format(tag) else: save_dir = args.save_dir modelDirectory = '{}/{}'.format(save_dir, tag) # Load the model train_model = GenerateModel(Nsrc=args.srcNum, inputFeature=args.featureFlag) print(train_model.summary()) # plot_model(train_model, to_file='Model.png') initial_epoch = 0 if args.continueToTrainFlag: savedModelDirectory = '{}/{}'.format('/Directory2TrainedModels', tag) try: savedModels = [ filename for path, subdirs, files in os.walk(savedModelDirectory) for filename in files if filename.endswith(".h5") ] if len(savedModels) > 0: index = [] for saveModelName in savedModels:
from GenerateModels import GenerateBSSCapsNet as GenerateModel tag = 'CapsNetModel' saveflag = 'Caps' elif modelMode == 4: tag = 'OracleIBM' saveflag = 'Oracle' print(tag) if modelMode < 4: ######################################### modelDirectory = './result04April/' + tag model = GenerateModel() # The separation model model.load_weights(modelDirectory + '/' + 'trained_model.h5') print(model.summary()) # plot_model(train_model, to_file='Model.png') import os for genderFlag in ['MM', 'MF', 'FF']: fullSaveDir = saveDirectoryTop + MatchedStr + '{}'.format(genderFlag) dataDir = folderName + MatchedStr + '{}/'.format(genderFlag) for azimuth in Azimuth_array: fullSaveDir_azi = fullSaveDir + '/{}/'.format(azimuth) if not os.path.exists(fullSaveDir_azi): os.makedirs(fullSaveDir_azi)
}) from GenerateModels import ChimeraNet as GenerateModel tag = 'Feature{}Nsrc{}{}'.format(['Proposed', 'SpecSpat', 'SpecOnly'][args.featureFlag], args.srcNum, ['', 'Wei'][args.outputFlag]) print(tag) modelDirectory = './TrainedModels' # from GenerateModelsOld import ChimeraNet as GenerateModel # tag = 'ChimeraNsrc{}{}'.format(args.srcNum,['','Wei'][args.outputFlag]) # print(tag) # modelDirectory = '/Directory2TrainedModels/ChimeraModels' # Load the model EncoderModel = GenerateModel(Nsrc=args.srcNum, inputFeature=args.featureFlag) # The separation model from keras.models import load_model EncoderModel = load_model("{}/{}/modelsave.h5".format(modelDirectory, tag)) # EncoderModel = load_model("{}/{}/modelsave.h5".format(modelDirectory,tag), custom_objects={'loss_DC': LossA(Nsrc=args.srcNum), 'lossMSE': LossB(Nsrc=args.srcNum)}) print(EncoderModel.summary()) # plot_model(train_model, to_file='Model.png') import itertools # tag = 'IBM' # comment this out later, this is for IBM baseline # tag = 'GMM' # comment this out later, this is for GMM baseline mseResults = np.zeros((N, ), dtype='float32') mseResults2 = np.zeros((N, ), dtype='float32')
elif args.outputFlag==1: from GenerateModels import EncoderNetBigLinear as GenerateModel tag = 'EncoderModel_{}_FF{}_CustomLoss'.format(['mel','linear'][args.outputFlag],args.featureFlag) print(tag) if args.save_dir is None: save_dir = './EncoderResult/Models/{}'.format(tag) else: save_dir = args.save_dir # Load the model train_model = GenerateModel() print(train_model.summary()) # plot_model(train_model, to_file='Model.png') initial_epoch = 0 if args.continueToTrainFlag: try: savedModels = [filename for path, subdirs, files in os.walk(save_dir) for filename in files if filename.endswith(".h5")] if len(savedModels)>0: index = [] for saveModelName in savedModels: temp = re.findall(r'(?<=model-)(\d+).h5', saveModelName)
from keras.utils.generic_utils import get_custom_objects from LossFuncs import my_loss as customLoss get_custom_objects().update({"my_loss": customLoss}) if args.outputFlag == 0: from GenerateModels import EncoderNetBigMel as GenerateModel elif args.outputFlag == 1: from GenerateModels import EncoderNetBigLinear as GenerateModel tag = 'EncoderModel_{}_FF{}_CustomLoss'.format(['mel', 'linear'][args.outputFlag], args.featureFlag) # Load the model EncoderModel = GenerateModel() # print(model.summary()) # plot_model(model, to_file='FrequencyModel.png') modelDirectory = './EncoderResultNov/Models/{}'.format(tag) # The separation model from keras.models import load_model EncoderModel = load_model("{}/ConvergeModel.h5".format(modelDirectory)) print(EncoderModel.summary()) # plot_model(train_model, to_file='Model.png') if args.synthesisFlag & args.outputFlag == 1: import os import librosa