コード例 #1
0
 def test_AnalysisWindow(self):
     start = 35000
     leng = 27333
     reference = self.reference[start:start+leng]
     factorization = SpleeterFactorization(self.dp, n_temporal_segments=1,
                                           composition_fn=None,
                                           model_name='spleeter:5stems',
                                           spleeter_sources_path=spleeter_sources_path)
     factorization.set_analysis_window(start, leng)
     all_components = factorization.compose_model_input()
     self.assertTrue(np.allclose(all_components, reference, atol=10 ** 5))
コード例 #2
0
        explainer = lime_audio.LimeAudioExplainer(verbose=True, absolute_feature_sort=False)

        for sn in range(len(snippet_starts)):

            if args.use_global_tag:
                labels = [top_idx]
            else:
                snippet_tag = top_tag_per_snippet[sn].item()
                labels = [snippet_tag]

            print("processing {}_{}".format(sample, sn))

            explanation_name = "{}/{}_cls{}_sntag{}_nc{}_sn{}_seg{}_smp{}_nd{}".format(config.model_type, sample, top_idx, labels[0], config.batch_size, sn, n_segments, num_samples, n_display_components)
            explanation_path = os.path.join(path_experiments, explanation_name + ".pt")

            spleeter_factorization.set_analysis_window(snippet_starts[sn], config.input_length)
            print("mix length", len(spleeter_factorization.data_provider.get_mix()))

            if os.path.exists(explanation_path) and not overwrite:
                print("Loading explanation ...")
                explanation = dill_load(explanation_path)
            else:
                print("(Re)computing explanation ...")
                explanation = explainer.explain_instance(factorization=spleeter_factorization,
                                                         predict_fn=predict_fn,
                                                         labels=labels,
                                                         num_samples=num_samples,
                                                         batch_size=batch_size
                                                         )
                dill_dump(explanation, explanation_path)