def decode(self, x, beamsize=5, threshold=1e-3, qscores=False, return_path=False): if beamsize == 1 or qscores: seq, path = viterbi_search(x, self.alphabet, qscores, self.qscale, self.qbias) else: seq, path = beam_search(x, self.alphabet, beamsize, threshold) if return_path: return seq, path return seq
def decode(x, beamsize=5, threshold=1e-3, qscores=False, return_path=False): """decode the output of CNN to ACTG Args: x: beamsize: threshold: qscores: return_path: Returns: """ alphabet = ["N", "A", "C", "G", "T"] if beamsize == 1 or qscores: qbias = 2.0 qscale = 0.7 seq, path = viterbi_search(x, alphabet, qscores, qscale, qbias) else: qbias = 0.0 qscale = 1.0 seq, path = beam_search(x, alphabet, beamsize, threshold) if return_path: return seq, path return seq
def decode(self, x, beamsize=5, threshold=1e-3, qscores=False, return_path=False): x = x.exp().cpu().numpy().astype(np.float32) if beamsize == 1 or qscores: seq, path = viterbi_search(x, self.alphabet, qscores, self.qscale, self.qbias) else: seq, path = beam_search(x, self.alphabet, beamsize, threshold) if return_path: return seq, path return seq
def process(self, raw, identifiers, frame_meta): if not self.label_map: raise ConfigError('Beam Search Decoder requires dataset label map for correct decoding.') alphabet = list(self.label_map.values()) raw_outputs = self._extract_predictions(raw, frame_meta) self.select_output_blob(raw_outputs) result = [] for identifier, out in zip(identifiers, np.exp(raw_outputs[self.output_blob])): if self.beam_size == 1: seq, _ = viterbi_search(np.squeeze(out), alphabet, False, 1, 0) else: seq, _ = beam_search(np.squeeze(out.astype(np.float32)), alphabet, self.beam_size, self.threshold) result.append(DNASequencePrediction(identifier, seq)) return result
def decode_ctc_greedy_rust(predictions, labels, *args): """ Argmax decoder with collapsing repeats in Rust """ seq, path = viterbi_search(predictions, labels) return seq