From 4b101ece44f448cf00faf165e8fc93338d9cf1d9 Mon Sep 17 00:00:00 2001
From: continue <steve.hcaa@gmail.com>
Date: Tue, 5 Nov 2019 15:40:43 +0800
Subject: [PATCH] Fix Sampler bug: index out of range when num_extra <
 len(indice) (#1610)

* Fix bug: index out of range when num_extra < len(indice)

* Fix bug: index out of range when num_extra < len(indice)

* formatter code
---
 mmdet/datasets/loader/sampler.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mmdet/datasets/loader/sampler.py b/mmdet/datasets/loader/sampler.py
index c610938..5bf2a70 100644
--- a/mmdet/datasets/loader/sampler.py
+++ b/mmdet/datasets/loader/sampler.py
@@ -57,7 +57,8 @@ class GroupSampler(Sampler):
             np.random.shuffle(indice)
             num_extra = int(np.ceil(size / self.samples_per_gpu)
                             ) * self.samples_per_gpu - len(indice)
-            indice = np.concatenate([indice, indice[:num_extra]])
+            indice = np.concatenate(
+                [indice, np.random.choice(indice, num_extra)])
             indices.append(indice)
         indices = np.concatenate(indices)
         indices = [
-- 
GitLab