From 3b11eb2f69bdc0fa41bc576ecd2b5d7c3824c67f Mon Sep 17 00:00:00 2001 From: Jacob Marks Date: Tue, 16 Jul 2024 22:16:47 -0500 Subject: [PATCH] efficient sample counting for grouped datasets --- fiftyone/utils/huggingface.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fiftyone/utils/huggingface.py b/fiftyone/utils/huggingface.py index b5fdb01913..e61b652a72 100644 --- a/fiftyone/utils/huggingface.py +++ b/fiftyone/utils/huggingface.py @@ -669,10 +669,10 @@ def _parse_subset_kwargs(**kwargs): def _count_samples(sample_collection): if sample_collection.media_type == "group": - return sum( - _count_samples(sample_collection.select_group_slices(s)) - for s in sample_collection.group_slices + sample_collection = sample_collection.select_group_slices( + _allow_mixed=True ) + return sample_collection.count()