Exemplo n.º 1
0
	def separate(self):
		# Input for KMeans algorithm [B, TF, E]
		input_kmeans = tf.reshape(self.prediction, [self.B, -1, self.embedding_size])
		self.embeddings = input_kmeans
		# S speakers to separate, give self.X in input not to consider silent bins
		kmeans = KMeans(nb_clusters=self.S, nb_tries=self.nb_tries, nb_iterations=self.nb_steps, 
			input_tensor=input_kmeans, beta=self.beta, latent_space_tensor=tf.abs(self.X) if self.with_silence else None,
			threshold=self.threshold)

		# Extract labels of each bins TF_i - labels [B, TF, 1]
		_ , labels = kmeans.network

		if self.beta is None:
			# It produces hard assignements [0,1,0, ...]
			self.masks = tf.one_hot(tf.cast(labels, tf.int32), self.S, 1.0, 0.0) # Create masks [B, TF, S]
		else:
			# It produces soft assignements
			self.masks = labels

		tf.summary.image('mask/predicted/1', tf.reshape(self.masks[:,:,0],[self.B, -1, self.F, 1]))
		tf.summary.image('mask/predicted/2', tf.reshape(self.masks[:,:,1],[self.B, -1, self.F, 1]))

		separated = tf.reshape(self.X, [self.B, -1, 1]) * self.masks # [B ,TF, S]
		if not self.plugged:
			separated = separated * tf.expand_dims((self.max_ - self.min_), 2) + tf.expand_dims(self.min_, 2)
			separated = tf.square(separated)
		separated = tf.reshape(separated, [self.B, -1, self.F, self.S])
		separated = tf.transpose(separated, [0,3,1,2]) # [B, S, T, F]
		separated = tf.reshape(separated, [self.B*self.S, -1, self.F, 1]) # [BS, T, F, 1]

		return separated
Exemplo n.º 2
0
	def separate(self):
		input_kmeans = tf.reshape(self.prediction, [self.B, -1, self.E])
		kmeans = KMeans(nb_clusters=2, nb_iterations=10, input_tensor=input_kmeans)
		_ , labels = kmeans.network
		masks = tf.one_hot(labels, 2, 1.0, 0.0, name='masks')
		self.ms = tf.reshape(masks, [self.B, -1, self.F, self.S])
		separated = tf.reshape(self.X, [self.B, -1, 1]) * masks # [B ,TF, S] 
		separated = tf.reshape(separated, [self.B, -1, self.F, self.S])
		separated = tf.transpose(separated, [0,3,1,2])
		separated = tf.reshape(separated, [self.B*self.S, -1, self.F, 1])
		print separated
		return separated
Exemplo n.º 3
0
	def separate(self):
		# TODO for only when Ind is available, speaker info is given
		# Ind [B, S, 1]
		Ind = tf.expand_dims(self.Ind, 2)

		# U [S_tot, E]
		centroids = tf.gather_nd(self.speaker_centroids, Ind)

		input_kmeans = tf.reshape(self.prediction, [self.B, -1, self.E])
		kmeans = KMeans(nb_clusters=2, nb_iterations=10, input_tensor=input_kmeans, centroids_init=centroids)
		_ , labels = kmeans.network
		
		masks = tf.one_hot(labels, 2, 1.0, 0.0)
		separated = tf.reshape(self.X, [self.B, -1, 1])* masks # [B ,TF, S] 
		separated = tf.reshape(separated, [self.B, -1, self.F, self.S])
		separated = tf.transpose(separated, [0,3,1,2])
		separated = tf.reshape(separated, [self.B*self.S, -1, self.F, 1])
		print separated
		return separated
Exemplo n.º 4
0
    def separate(self):
        # Input for KMeans algorithm [B, TF, E]
        input_kmeans = tf.reshape(self.prediction,
                                  [self.B, -1, self.embedding_size])
        # S speakers to separate, give self.X in input not to consider silent bins
        kmeans = KMeans(nb_clusters=self.S,
                        nb_iterations=10,
                        input_tensor=input_kmeans,
                        latent_space_tensor=self.X)

        # Extract labels of each bins TF_i - labels [B, TF, 1]
        _, labels = kmeans.network
        self.masks = tf.one_hot(labels, 2, 1.0, 0.0)  # Create masks [B, TF, S]

        separated = tf.reshape(self.X,
                               [self.B, -1, 1]) * self.masks  # [B ,TF, S]
        separated = tf.reshape(separated, [self.B, -1, self.F, self.S])
        separated = tf.transpose(separated, [0, 3, 1, 2])  # [B, S, T, F]
        separated = tf.reshape(
            separated, [self.B * self.S, -1, self.F, 1])  # [BS, T, F, 1]

        return separated
Exemplo n.º 5
0
Arquivo: L41.py Projeto: Qoboty/das
	def separate(self):
		# TODO for only when Ind is available, speaker info is given
		# Ind [B, S, 1]
		# Ind = tf.expand_dims(self.I, 2)

		# U [S_tot, E]
		# centroids = tf.gather_nd(self.speaker_vectors, Ind)

		# Input for KMeans algorithm [B, TF, E]
		input_kmeans = tf.reshape(self.prediction, [self.B, -1, self.embedding_size])
		# S speakers to separate, give self.X in input not to consider silent bins
		kmeans = KMeans(nb_clusters=self.S, nb_iterations=10, input_tensor=input_kmeans, latent_space_tensor=self.X)
		
		# Extract labels of each bins TF_i - labels [B, TF, 1]
		_ , labels = kmeans.network
		print labels
		self.masks = tf.one_hot(labels, 2, 1.0, 0.0) # Create masks [B, TF, S]

		separated = tf.reshape(self.X, [self.B, -1, 1])* self.masks # [B ,TF, S] 
		separated = tf.reshape(separated, [self.B, -1, self.F, self.S])
		separated = tf.transpose(separated, [0,3,1,2]) # [B, S, T, F]
		separated = tf.reshape(separated, [self.B*self.S, -1, self.F, 1]) # [BS, T, F, 1]

		return separated