def setUp(self): add_taxonomy_nodes(Taxonomy.objects.get()) create_sounds('fsd', 10) create_users(1) user = User.objects.first() dataset = Dataset.objects.get(short_name='fsd') dataset.maintainers.add(user) dataset.save() create_candidate_annotations('fsd', 20) # create ground truth annotations for candidate_annotation in CandidateAnnotation.objects.all(): gt_annotation, created = GroundTruthAnnotation.objects.get_or_create( start_time=candidate_annotation.start_time, end_time=candidate_annotation.end_time, ground_truth=candidate_annotation.ground_truth, created_by=candidate_annotation.created_by, sound_dataset=candidate_annotation.sound_dataset, taxonomy_node=candidate_annotation.taxonomy_node, from_propagation=False) gt_annotation.from_candidate_annotations.add(candidate_annotation) # add preview url for sounds sounds = Sound.objects.all() with transaction.atomic(): for sound in sounds: sound.extra_data[ 'previews'] = 'http://www.freesound.org/data/previews/188/188440_3399958-hq.ogg' sound.save() self.client.login(username='******', password='******')
def setUp(self): add_taxonomy_nodes(Taxonomy.objects.get()) create_users(1) user = User.objects.first() # creates 24 sounds with length [0.3, 10] and [10, 20], and their annotations dataset = get_dataset('fsd') node = dataset.taxonomy.taxonomynode_set.first() num_current_sounds = Sound.objects.all().count() fsids = [VALID_FS_IDS[i % len(VALID_FS_IDS)] for i in range(0, 24)] with transaction.atomic(): for count, fsid in enumerate(fsids): sound = Sound.objects.create( name='Freesound sound #{0}'.format(count + num_current_sounds), freesound_id=fsid, extra_data={ 'duration': 0.3 + 5 * random.random() if count < 12 else 10 + 10 * random.random(), 'previews': 'http://www.freesound.org/data/previews/188/188440_3399958-hq.ogg' }) sound_dataset = SoundDataset.objects.create(dataset=dataset, sound=sound) candidate_annotation = CandidateAnnotation.objects.create( sound_dataset=sound_dataset, taxonomy_node=node, type='AU', algorithm='Fake algorithm name', created_by=user) candidate_annotation.update_priority_score()
def setUp(self): # For these tests we create only one sound and one candidate annotation add_taxonomy_nodes(models.Taxonomy.objects.get()) create_sounds('fsd', 1) create_users(2) create_candidate_annotations('fsd', 1) self.users = models.User.objects.all() self.dataset = models.Dataset.objects.get(short_name='fsd') self.candidate_annotation = models.CandidateAnnotation.objects.first()
def setUp(self): add_taxonomy_nodes(Taxonomy.objects.get()) create_sounds('fsd', 10) create_users(5) create_candidate_annotations('fsd', 20) # add preview url for sounds sounds = Sound.objects.all() with transaction.atomic(): for sound in sounds: sound.extra_data['previews'] = 'http://www.freesound.org/data/previews/188/188440_3399958-hq.ogg' sound.save() self.node_with_candidates = CandidateAnnotation.objects.first().taxonomy_node self.client.login(username='******', password='******')
def setUp(self): # For these tests we create only one sound and one candidate annotation add_taxonomy_nodes(models.Taxonomy.objects.get()) create_sounds('fsd', 1) create_users(2) create_candidate_annotations('fsd', 1) candidate_annotation = models.CandidateAnnotation.objects.first() users = models.User.objects.all() self.dataset = models.Dataset.objects.get(short_name='fsd') # create 2 votes for the candidate annotations (it should create ground truth annotations) for user in users: self.dataset.maintainers.add(user) models.Vote.objects.create( created_by=user, vote=1.0, visited_sound=False, candidate_annotation_id=candidate_annotation.id, test='AP', from_test_page=True, from_task='AD', ) self.dataset.save()
def setUp(self): add_taxonomy_nodes(Taxonomy.objects.get()) create_sounds('fsd', 1) create_users(1) create_candidate_annotations('fsd', 1)
def setUp(self): taxonomy = { "1": { "id": "1", "name": "1", "description": "This is a root category", "child_ids": ["2"], "restrictions": [], "citation_uri": "", }, "2": { "id": "2", "name": "2", "description": "This is a simple non-root & non-leaf category", "child_ids": ["3"], "parent_ids": ["1"], "propagate_to_parent_ids": ["1"], "restrictions": [], "citation_uri": "", }, "3": { "id": "3", "name": "3", "description": "This category has two parents", "child_ids": [], "parent_ids": ["2", "5"], "propagate_to_parent_ids": ["5"], "restrictions": [], "citation_uri": "", }, "4": { "id": "4", "name": "4", "description": "This is a leaf category", "child_ids": [], "parent_ids": ["5"], "propagate_to_parent_ids": ["5"], "restrictions": [], "citation_uri": "", }, "5": { "id": "5", "name": "5", "description": "This is a root category", "child_ids": ["3", "4"], "restrictions": [], "citation_uri": "", }, } self.taxobj = models.Taxonomy.objects.create(data=taxonomy) add_taxonomy_nodes(self.taxobj) models.Dataset.objects.create(short_name='fsd', taxonomy=self.taxobj) create_sounds('fsd', 1) create_users(1) self.sound = models.Sound.objects.first() self.user = models.User.objects.first() self.taxonomy_node = self.taxobj.get_element_at_id( "3") # a children node self.second_taxonomy_node = self.taxobj.get_element_at_id( "4") # a children node # a root node which is propagated from the two nodes above self.taxonomy_node_to_propagate_to = self.taxobj.get_element_at_id("5") create_candidate_annotations('fsd', 1) self.candidate_annotation = models.CandidateAnnotation.objects.create( sound_dataset=self.sound.sounddataset_set.first(), type='AU', algorithm='Fake algorithm name', taxonomy_node=self.taxonomy_node, ground_truth=1.0, ) self.users = models.User.objects.all() self.dataset = models.Dataset.objects.get(short_name='fsd') # self.candidate_annotation = models.CandidateAnnotation.objects.first() # self.candidate_annotation.ground_truth = 1.0 self.candidate_annotation.save() self.gt_annotation = models.GroundTruthAnnotation.objects.create( ground_truth=1.0, created_by=self.user, sound_dataset=self.sound.sounddataset_set.first(), taxonomy_node=self.taxonomy_node) self.gt_annotation.from_candidate_annotations.add( self.candidate_annotation)