Example #1
0
    def test02TheStftKnowsHowMuchPaddingItShouldApply(self):
        self.assertEquals(self.anStftForTheInpaintingSetting.padding(), self.fft_window_length-self.fft_hop_size)

        fft_window_length = 1024
        fft_hop_size = 128
        params = LstmContextInpaintingParameters(lstmSize=512, batchSize=64, signalLength=self.signal_length,
                                                 gapLength=self.gap_length,
                                                 fftWindowLength=fft_window_length, fftHopSize=fft_hop_size)

        anStftForTheInpaintingSetting = PreAndPostProcessor(params)
        self.assertEquals(anStftForTheInpaintingSetting.padding(), fft_window_length - fft_hop_size)

        fft_window_length = 1024
        fft_hop_size = 256
        params = LstmContextInpaintingParameters(lstmSize=512, batchSize=64, signalLength=self.signal_length,
                                                 gapLength=self.gap_length,
                                                 fftWindowLength=fft_window_length, fftHopSize=fft_hop_size)

        anStftForTheInpaintingSetting = PreAndPostProcessor(params)
        self.assertEquals(anStftForTheInpaintingSetting.padding(), fft_window_length - fft_hop_size)
Example #2
0
    def setUp(self):
        self.signal_length = 5120
        self.gap_length = 1024
        self.fft_window_length = 512
        self.fft_hop_size = 128

        self.params = LstmContextInpaintingParameters(lstmSize=512, batchSize=64, signalLength=self.signal_length,
                                                      gapLength=self.gap_length,
                                                 fftWindowLength=self.fft_window_length, fftHopSize=self.fft_hop_size)

        self.anStftForTheInpaintingSetting = PreAndPostProcessor(self.params)
Example #3
0
    def test03TheStftKnowsWhatSignalItShouldTakeForTheSTFTOfTheGap(self):
        fake_batch_of_signal = np.array([np.arange(self.signal_length)])
        produced_signal = self.anStftForTheInpaintingSetting._removeExtraSidesForSTFTOfGap(fake_batch_of_signal)

        gap_begins = (self.signal_length-self.gap_length)//2
        gap_ends = gap_begins + self.gap_length
        padding = self.fft_window_length-self.fft_hop_size

        np.testing.assert_almost_equal(fake_batch_of_signal[:, gap_begins - padding:gap_ends + padding], produced_signal)

        fft_window_length = 128
        fft_hop_size = 32
        params = LstmContextInpaintingParameters(lstmSize=512, batchSize=64, signalLength=self.signal_length,
                                                 gapLength=self.gap_length,
                                                 fftWindowLength=fft_window_length, fftHopSize=fft_hop_size)


        anStftForTheInpaintingSetting = PreAndPostProcessor(params)
        produced_signal = anStftForTheInpaintingSetting._removeExtraSidesForSTFTOfGap(fake_batch_of_signal)
        padding = fft_window_length - fft_hop_size
        np.testing.assert_almost_equal(fake_batch_of_signal[:, gap_begins - padding:gap_ends + padding], produced_signal)
from architecture.parameters.lstmContextInpaintingParameters import LstmContextInpaintingParameters
from architecture.realImagContextEncoderLSTMArchitecture import RealImagContextEncoderLSTMArchitecture
import os

from system.preAndPostProcessor import PreAndPostProcessor
from system.realImagContextLSTMSystem import RealImagContextLSTMSystem

os.environ["CUDA_VISIBLE_DEVICES"] = "0"

sessionsName = "test_nsynth2048_bs256_fft512_"

params = LstmContextInpaintingParameters(lstmSize=512,
                                         batchSize=256,
                                         signalLength=6144,
                                         inputChannels=4,
                                         gapLength=2048,
                                         fftWindowLength=512,
                                         fftHopSize=128)

contextArchitecture = RealImagContextEncoderLSTMArchitecture(params)

aPreProcessor = PreAndPostProcessor(params)

aContextEncoderSystem = RealImagContextLSTMSystem(contextArchitecture,
                                                  aPreProcessor, params,
                                                  sessionsName)

aContextEncoderSystem.train(
    "../../aDataset/nsynth_train_w6144_g2048_h512.tfrecords",
    "../../aDataset/nsynth_valid_w6144_g2048_h512.tfrecords", 1e-4)
Example #5
0
from architecture.contextEncoderLSTMArchitecture import ContextEncoderLSTMArchitecture
from architecture.parameters.lstmContextInpaintingParameters import LstmContextInpaintingParameters
from system.lstmSystem import LSTMSystem
import os

from system.preAndPostProcessor import PreAndPostProcessor

os.environ["CUDA_VISIBLE_DEVICES"] = "0"

sessionsName = "test_ContextLSTM_"

params = LstmContextInpaintingParameters(lstmSize=512,
                                         batchSize=64,
                                         signalLength=5120,
                                         inputChannels=4,
                                         gapLength=1024,
                                         fftWindowLength=512,
                                         fftHopSize=128)

contextArchitecture = ContextEncoderLSTMArchitecture(params)

aPreProcessor = PreAndPostProcessor(params)

aContextEncoderSystem = LSTMSystem(contextArchitecture, aPreProcessor, params,
                                   sessionsName)

aContextEncoderSystem.train(
    "../variationalAutoEncoder/fake_w5120_g1024_h512.tfrecords",
    "../variationalAutoEncoder/fake_w5120_g1024_h512.tfrecords", 1e-3)
Example #6
0
from architecture.parameters.lstmContextInpaintingParameters import LstmContextInpaintingParameters
from architecture.realImagContextEncoderLSTMArchitecture import RealImagContextEncoderLSTMArchitecture
import os

from system.preAndPostProcessor import PreAndPostProcessor
from system.realImagContextLSTMSystem import RealImagContextLSTMSystem

os.environ["CUDA_VISIBLE_DEVICES"] = "0"

sessionsName = "test_nsynth4096_bs256_fft256_"

params = LstmContextInpaintingParameters(lstmSize=512,
                                         batchSize=256,
                                         signalLength=12288,
                                         inputChannels=4,
                                         gapLength=4096,
                                         fftWindowLength=256,
                                         fftHopSize=64)

contextArchitecture = RealImagContextEncoderLSTMArchitecture(params)

aPreProcessor = PreAndPostProcessor(params)

aContextEncoderSystem = RealImagContextLSTMSystem(contextArchitecture,
                                                  aPreProcessor, params,
                                                  sessionsName)

aContextEncoderSystem.train(
    "../../aDataset/nsynth_train_w12288_g4096_h512.tfrecords",
    "../../aDataset/nsynth_valid_w12288_g4096_h512.tfrecords", 1e-3)