def test_multiple_fields(self):
    dataset = foz.load_zoo_dataset('open-images-v6', split='validation', label_types=['detections', 'segmentations', 'classifications'], classes=['Person'], max_samples=10).clone()
    prev_dataset = dataset.clone()
    anno_key = 'anno_key'
    label_schema = {'detections': {}, 'segmentations': {'type': 'instances'}, 'positive_labels': {}, 'negative_labels': {}}
    results = dataset.annotate(anno_key, backend='cvat', label_schema=label_schema, classes=['Person'])
    api = results.connect_to_api()
    task_id = results.task_ids[0]
    dataset.load_annotations(anno_key, cleanup=True)
    api.close()

    def _remove_bbox(dataset, label_field):
        view = dataset.set_field(('%s.detections' % label_field), F('detections').map(F().set_field('bounding_box', []).set_field('mask', None)))
        return view
    view = _remove_bbox(dataset, 'detections')
    prev_view = _remove_bbox(prev_dataset, 'detections')
    self.assertListEqual(view.values('detections', unwind=True), prev_view.values('detections', unwind=True))
    view = _remove_bbox(dataset, 'segmentations')
    prev_view = _remove_bbox(prev_dataset, 'segmentations')
    self.assertListEqual(view.values('segmentations', unwind=True), prev_view.values('segmentations', unwind=True))
    self.assertListEqual(dataset.values('positive_labels', unwind=True), prev_dataset.values('positive_labels', unwind=True))
    self.assertListEqual(dataset.values('negative_labels', unwind=True), prev_dataset.values('negative_labels', unwind=True))
def test_multiple_fields(self):
    dataset = foz.load_zoo_dataset('open-images-v6', split='validation', label_types=['detections', 'segmentations', 'classifications'], classes=['Person'], max_samples=10).clone()
    prev_dataset = dataset.clone()
    anno_key = 'anno_key'
    label_schema = {'detections': {}, 'segmentations': {'type': 'instances'}, 'positive_labels': {}, 'negative_labels': {}}
    results = dataset.annotate(anno_key, backend='cvat', label_schema=label_schema, classes=['Person'])
    api = results.connect_to_api()
    task_id = results.task_ids[0]
    dataset.load_annotations(anno_key, cleanup=True)
    api.close()

    def _remove_bbox(dataset, label_field):
        view = dataset.set_field(('%s.detections' % label_field), F('detections').map(F().set_field('bounding_box', []).set_field('mask', None)))
        return view
    view = _remove_bbox(dataset, 'detections')
    prev_view = _remove_bbox(prev_dataset, 'detections')
    self.assertListEqual(view.values('detections', unwind=True), prev_view.values('detections', unwind=True))
    view = _remove_bbox(dataset, 'segmentations')
    prev_view = _remove_bbox(prev_dataset, 'segmentations')
    self.assertListEqual(view.values('segmentations', unwind=True), prev_view.values('segmentations', unwind=True))
    self.assertListEqual(dataset.values('positive_labels', unwind=True), prev_dataset.values('positive_labels', unwind=True))
    self.assertListEqual(dataset.values('negative_labels', unwind=True), prev_dataset.values('negative_labels', unwind=True))