Download preprocess/humanparsing/mhp_extension/detectron2/tests/data/test_sampler.py from Navyssh/StyleSync: direct link, hf CLI and curl.
- Browser
- Download file 800 Bytes
-
https://huggingface.co/Navyssh/StyleSync/resolve/main/preprocess/humanparsing/mhp_extension/detectron2/tests/data/test_sampler.py
- Command line
-
hf download hf://Navyssh/StyleSync/preprocess/humanparsing/mhp_extension/detectron2/tests/data/test_sampler.py
-
curl -L -o test_sampler.py https://huggingface.co/Navyssh/StyleSync/resolve/main/preprocess/humanparsing/mhp_extension/detectron2/tests/data/test_sampler.py
800 Bytes
| # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | |
| import unittest | |
| from torch.utils.data.sampler import SequentialSampler | |
| from detectron2.data.samplers import GroupedBatchSampler | |
| class TestGroupedBatchSampler(unittest.TestCase): | |
| def test_missing_group_id(self): | |
| sampler = SequentialSampler(list(range(100))) | |
| group_ids = [1] * 100 | |
| samples = GroupedBatchSampler(sampler, group_ids, 2) | |
| for mini_batch in samples: | |
| self.assertEqual(len(mini_batch), 2) | |
| def test_groups(self): | |
| sampler = SequentialSampler(list(range(100))) | |
| group_ids = [1, 0] * 50 | |
| samples = GroupedBatchSampler(sampler, group_ids, 2) | |
| for mini_batch in samples: | |
| self.assertEqual((mini_batch[0] + mini_batch[1]) % 2, 0) | |