def test_multiannotator(): # test good data annotators = ["annotator_1", "annotator_2"] labels_1 = ["Siren", "Engine"] labels_2 = ["Siren", "Dog"] confidence_1 = np.array([1.0, 1.0]) confidence_2 = np.array([1.0, 1.0]) multi_annot = [ annotations.Tags(labels_1, "open", confidence_1), annotations.Tags(labels_2, "open", confidence_2), ] tags = annotations.MultiAnnotator(annotators, multi_annot) assert tags.annotations[0].labels == labels_1 assert tags.annotators[1] == "annotator_2" assert np.allclose(tags.annotations[1].confidence, confidence_2) # test bad data bad_labels = ["Siren", "Laughter", 5] pytest.raises(TypeError, annotations.MultiAnnotator, annotators, bad_labels) pytest.raises(TypeError, annotations.MultiAnnotator, [0, 1], multi_annot) pytest.raises( TypeError, annotations.MultiAnnotator, annotators, [["bad", "format"], ["indeed"]], )
def mids(self): return annotations.Tags( self._clip_metadata["ground_truth"].get("mids"), "open", np.array([1.0] * len(self._clip_metadata["ground_truth"].get("tags"))), )
def test_tags(): # test good data labels = ["Siren", "Laughter", "Engine"] confidence = np.array([1.0, 0.0, 1.0]) tags = annotations.Tags(labels, "open", confidence) assert tags.labels == labels assert np.allclose(tags.confidence, confidence) # test bad data bad_labels = ["Siren", "Laughter", 5] pytest.raises(TypeError, annotations.Tags, bad_labels, "open", confidence) bad_confidence = np.array([1, 0.5, -0.2]) pytest.raises(ValueError, annotations.Tags, labels, "open", bad_confidence) # test units with pytest.raises(ValueError): annotations.Tags(labels, "bad_unit", confidence)
def tags(self): """The clip's tags. Returns: * annotations.Tags - tag (label) of the clip + confidence. In UrbanSound8K every clip has one tag """ return annotations.Tags([self._clip_metadata.get("class_label")], "open", np.array([1.0]))
def tags(self): """The clip's tags. Returns: * annotations.Tags - tag (label) of the clip + confidence """ return annotations.Tags( [self._clip_metadata.get("tag")], "open", np.array([1.0]) )
def tags(self): """The clip's audio Returns: * np.ndarray - audio signal * float - sample rate """ return annotations.Tags( [self._clip_metadata.get("category")], "open", np.array([1.0]) )
def tags(self): """The clip's tags. Returns: * annotations.Tags - tag (scene label) of the clip + confidence. """ scene_label = self._clip_metadata.get("scene_label") if scene_label is None: return None else: return annotations.Tags([scene_label], "open", np.array([1.0]))
def test_multiannotator_tags(): tag_data1 = annotations.Tags( ["blues", "I am a description"], "open", np.array([1.0, 1.0]) ) tag_data2 = annotations.Tags( ["reds", "We are a description"], "open", np.array([1.0, 1.0]) ) tag_data3 = annotations.Tags( ["greens", "They are description"], "open", np.array([1.0, 1.0]) ) multiannotator_data = annotations.MultiAnnotator( ["01", "02", "03"], [tag_data1, tag_data2, tag_data3] ) jam = jams_utils.jams_converter( tags=multiannotator_data, metadata={"duration": 10.0} ) assert jam.validate()
def mids(self): """The clip's mids. Returns: * annotations.Tags - tag (labels) encoded in Audioset formatting """ return annotations.Tags( self._clip_metadata["ground_truth"].get("mids"), "open", np.array([1.0] * len(self._clip_metadata["ground_truth"].get("tags"))), )
def tags(self): """The clip's tags. Returns: * annotations.Tags - tag (label) of the clip + confidence """ return annotations.Tags( self._clip_metadata["ground_truth"].get("tags"), "open", np.array([1.0] * len(self._clip_metadata["ground_truth"].get("tags"))), )
def test_tags(): tag_data1 = annotations.Tags( ["blues", "I am a description"], "open", np.array([1.0, 1.0]) ) tag_data3 = ("jazz", "wrong format") tag_data4 = [(123, "asdf")] jam1 = jams_utils.jams_converter(tags=tag_data1, metadata={"duration": 10.0}) assert jam1.validate() with pytest.raises(TypeError): jams_utils.jams_converter(tags=tag_data3) with pytest.raises(TypeError): jams_utils.jams_converter(tags=tag_data4)
def tags(self): return annotations.Tags([self._clip_metadata.get("class_label")], "open", np.array([1.0]))
def tags(self): return annotations.Tags([self._clip_metadata.get("category")], "open", np.array([1.0]))
def tags(self): scene_label = self._clip_metadata.get("scene_label") if scene_label is None: return None else: return annotations.Tags([scene_label], "open", np.array([1.0]))