From 3dc9ddb73315f016d782fdeb824ec1f5ef2e9f81 Mon Sep 17 00:00:00 2001
From: kkkio <kevin.l.yide@gmail.com>
Date: Wed, 25 Sep 2019 08:35:42 +0100
Subject: [PATCH] Fix #1223 (#1404)

* Fix #1223

#1223  is caused by extra > len(indice), so I add a loop to properly pad the indice list. I also changed the list concatenation from ```+=``` to ```.extend```.

* Update sampler.py

style
---
 mmdet/datasets/loader/sampler.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/mmdet/datasets/loader/sampler.py b/mmdet/datasets/loader/sampler.py
index 6c52900..c610938 100644
--- a/mmdet/datasets/loader/sampler.py
+++ b/mmdet/datasets/loader/sampler.py
@@ -132,8 +132,12 @@ class DistributedGroupSampler(Sampler):
                     math.ceil(
                         size * 1.0 / self.samples_per_gpu / self.num_replicas)
                 ) * self.samples_per_gpu * self.num_replicas - len(indice)
-                indice += indice[:extra]
-                indices += indice
+                # pad indice
+                tmp = indice.copy()
+                for _ in range(extra // size):
+                    indice.extend(tmp)
+                indice.extend(tmp[:extra % size])
+                indices.extend(indice)
 
         assert len(indices) == self.total_size
 
-- 
GitLab