Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Commit

Permalink
use deepcopy in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
knorth55 committed May 20, 2019
1 parent 1d9295c commit b914fe8
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
import numpy as np
import unittest

Expand Down Expand Up @@ -28,7 +29,7 @@ class TestFCISResNet101(unittest.TestCase):
n_test_post_nms = 8

def setUp(self):
params = FCISResNet101.preset_params['sbd'].copy()
params = copy.deepcopy(FCISResNet101.preset_params['sbd'])
params['n_fg_class'] = self.n_fg_class
proposal_creator_params = params['proposal_creator_params']
proposal_creator_params['n_train_post_nms'] = self.n_train_post_nms
Expand Down Expand Up @@ -94,7 +95,7 @@ class TestFCISResNet101Loss(unittest.TestCase):
n_test_post_nms = 8

def setUp(self):
params = FCISResNet101.preset_params['sbd'].copy()
params = copy.deepcopy(FCISResNet101.preset_params['sbd'])
params['n_fg_class'] = self.n_fg_class
proposal_creator_params = params['proposal_creator_params']
proposal_creator_params['n_train_post_nms'] = self.n_train_post_nms
Expand Down Expand Up @@ -136,9 +137,9 @@ class TestFCISResNet101Pretrained(unittest.TestCase):
@attr.slow
def test_pretrained(self):
if self.pretrained_model.startswith('sbd'):
params = FCISResNet101.preset_params['sbd'].copy()
params = copy.deepcopy(FCISResNet101.preset_params['sbd'])
elif self.pretrained_model.startswith('coco'):
params = FCISResNet101.preset_params['coco'].copy()
params = copy.deepcopy(FCISResNet101.preset_params['coco'])
params['n_fg_class'] = self.n_fg_class
params['anchor_scales'] = self.anchor_scales

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
import numpy as np
import unittest

Expand All @@ -19,7 +20,7 @@ class TestPSPNetResNet(unittest.TestCase):
def setUp(self):
self.n_class = 10
self.input_size = (120, 160)
params = self.model.preset_params['cityscapes'].copy()
params = copy.deepcopy(self.model.preset_params['cityscapes'])
params['n_class'] = self.n_class
params['input_size'] = self.input_size
self.link = self.model(**params)
Expand Down Expand Up @@ -66,7 +67,7 @@ class TestPSPNetResNetPretrained(unittest.TestCase):

@attr.slow
def test_pretrained(self):
params = self.model.preset_params['cityscapes'].copy()
params = copy.deepcopy(self.model.preset_params['cityscapes'])
params['n_class'] = self.n_class

if self.pretrained_model == 'cityscapes':
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
import numpy as np
import unittest

Expand All @@ -14,7 +15,7 @@
class TestYOLOv2Tiny(unittest.TestCase):

def setUp(self):
params = YOLOv2Tiny.preset_params['voc'].copy()
params = copy.deepcopy(YOLOv2Tiny.preset_params['voc'])
params['n_fg_class'] = self.n_fg_class
self.link = YOLOv2Tiny(**params)
self.insize = 416
Expand Down Expand Up @@ -58,7 +59,7 @@ class TestYOLOv2TinyPretrained(unittest.TestCase):

@attr.slow
def test_pretrained(self):
params = YOLOv2Tiny.preset_params['voc'].copy()
params = copy.deepcopy(YOLOv2Tiny.preset_params['voc'])
params['n_fg_class'] = self.n_fg_class

if self.pretrained_model == 'voc0712':
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
import unittest

import chainer
Expand All @@ -17,7 +18,7 @@ class TestDeepLabV3plusXception65(unittest.TestCase):

def setUp(self):
self.n_class = 10
params = self.model.preset_params['voc'].copy()
params = copy.deepcopy(self.model.preset_params['voc'])
params['n_class'] = self.n_class
self.link = self.model(**params)

Expand Down Expand Up @@ -62,7 +63,7 @@ class TestDeepLabV3plusXception65Pretrained(unittest.TestCase):

@attr.slow
def test_pretrained(self):
params = self.model.preset_params[self.pretrained_model].copy()
params = copy.deepcopy(self.model.preset_params[self.pretrained_model])
params['n_class'] = self.n_class

if self.pretrained_model == 'cityscapes':
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
import numpy as np
import unittest

Expand Down Expand Up @@ -25,7 +26,7 @@ class TestFasterRCNNVGG16(unittest.TestCase):
n_conv5_3_channel = 512

def setUp(self):
params = FasterRCNNVGG16.preset_params['voc'].copy()
params = copy.deepcopy(FasterRCNNVGG16.preset_params['voc'])
params['n_fg_class'] = self.n_fg_class
proposal_creator_params = params['proposal_creator_params']
proposal_creator_params['n_train_post_nms'] = self.n_train_post_nms
Expand Down Expand Up @@ -78,7 +79,7 @@ class TestFasterRCNNVGG16Loss(unittest.TestCase):
n_fg_class = 20

def setUp(self):
params = FasterRCNNVGG16.preset_params['voc'].copy()
params = copy.deepcopy(FasterRCNNVGG16.preset_params['voc'])
params['n_fg_class'] = self.n_fg_class
faster_rcnn = FasterRCNNVGG16(pretrained_model=None, **params)
self.link = FasterRCNNTrainChain(faster_rcnn)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
import numpy as np
import unittest

Expand All @@ -19,7 +20,7 @@
class TestFasterRCNNFPNResNet(unittest.TestCase):

def setUp(self):
params = self.model.preset_params['coco'].copy()
params = copy.deepcopy(self.model.preset_params['coco'])
params['n_fg_class'] = self.n_fg_class
params['min_size'] = 66
self.link = self.model(**params)
Expand Down Expand Up @@ -55,7 +56,7 @@ class TestFasterRCNNFPNResNetPretrained(unittest.TestCase):

@attr.slow
def test_pretrained(self):
params = self.model.preset_params['coco'].copy()
params = copy.deepcopy(self.model.preset_params['coco'])
params['n_fg_class'] = self.n_fg_class

if self.pretrained_model == 'coco':
Expand Down
5 changes: 3 additions & 2 deletions tests/links_tests/model_tests/resnet_tests/test_resnet.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest

import copy
import numpy as np

from chainer.testing import attr
Expand Down Expand Up @@ -34,7 +35,7 @@
class TestResNetCall(unittest.TestCase):

def setUp(self):
params = self.model_class.preset_params['imagenet'].copy()
params = copy.deepcopy(self.model_class.preset_params['imagenet'])
params['n_class'] = self.n_class
self.link = self.model_class(
pretrained_model=None, arch=self.arch, **params)
Expand Down Expand Up @@ -75,7 +76,7 @@ class TestResNetPretrained(unittest.TestCase):

@attr.slow
def test_pretrained(self):
params = self.model.preset_params[self.pretrained_model].copy()
params = copy.deepcopy(self.model.preset_params[self.pretrained_model])
params['n_class'] = self.n_class
params['mean'] = self.mean

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
import numpy as np
import unittest

Expand All @@ -17,7 +18,7 @@ class TestSegNetBasic(unittest.TestCase):

def setUp(self):
self.n_class = 10
params = SegNetBasic.preset_params['camvid'].copy()
params = copy.deepcopy(SegNetBasic.preset_params['camvid'])
params['n_class'] = self.n_class
self.link = SegNetBasic(**params)

Expand Down Expand Up @@ -60,7 +61,7 @@ class TestSegNetPretrained(unittest.TestCase):

@attr.slow
def test_pretrained(self):
params = SegNetBasic.preset_params['camvid'].copy()
params = copy.deepcopy(SegNetBasic.preset_params['camvid'])
params['n_class'] = self.n_class

if self.pretrained_model == 'camvid':
Expand Down
5 changes: 3 additions & 2 deletions tests/links_tests/model_tests/senet_tests/test_se_resnet.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest

import copy
import numpy as np

from chainer.testing import attr
Expand Down Expand Up @@ -30,7 +31,7 @@
class TestSEResNetCall(unittest.TestCase):

def setUp(self):
params = self.model_class.preset_params['imagenet'].copy()
params = copy.deepcopy(self.model_class.preset_params['imagenet'])
params['n_class'] = self.n_class
self.link = self.model_class(
pretrained_model=None, **params)
Expand Down Expand Up @@ -70,7 +71,7 @@ class TestSEResNetPretrained(unittest.TestCase):

@attr.slow
def test_pretrained(self):
params = self.model.preset_params[self.pretrained_model].copy()
params = copy.deepcopy(self.model.preset_params[self.pretrained_model])
params['n_class'] = self.n_class
params['mean'] = self.mean

Expand Down
5 changes: 3 additions & 2 deletions tests/links_tests/model_tests/senet_tests/test_se_resnext.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest

import copy
import numpy as np

from chainer.testing import attr
Expand Down Expand Up @@ -28,7 +29,7 @@
class TestSEResNeXtCall(unittest.TestCase):

def setUp(self):
params = self.model_class.preset_params['imagenet'].copy()
params = copy.deepcopy(self.model_class.preset_params['imagenet'])
params['n_class'] = self.n_class
self.link = self.model_class(
pretrained_model=None, **params)
Expand Down Expand Up @@ -68,7 +69,7 @@ class TestSEResNeXtPretrained(unittest.TestCase):

@attr.slow
def test_pretrained(self):
params = self.model.preset_params[self.pretrained_model].copy()
params = copy.deepcopy(self.model.preset_params[self.pretrained_model])
params['n_class'] = self.n_class
params['mean'] = self.mean

Expand Down
7 changes: 4 additions & 3 deletions tests/links_tests/model_tests/ssd_tests/test_ssd_vgg16.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
import numpy as np
import unittest

Expand All @@ -17,12 +18,12 @@ class TestSSDVGG16(unittest.TestCase):

def setUp(self):
if self.insize == 300:
params = SSD300.preset_params['voc'].copy()
params = copy.deepcopy(SSD300.preset_params['voc'])
params['n_fg_class'] = self.n_fg_class
self.link = SSD300(**params)
self.n_bbox = 8732
elif self.insize == 512:
params = SSD300.preset_params['voc'].copy()
params = copy.deepcopy(SSD300.preset_params['voc'])
params['n_fg_class'] = self.n_fg_class
self.link = SSD512(**params)
self.n_bbox = 24564
Expand Down Expand Up @@ -61,7 +62,7 @@ class TestSSDVGG16Pretrained(unittest.TestCase):

@attr.slow
def test_pretrained(self):
params = self.model.preset_params['voc'].copy()
params = copy.deepcopy(self.model.preset_params['voc'])
params['n_fg_class'] = self.n_fg_class

if self.pretrained_model == 'voc0712':
Expand Down
5 changes: 3 additions & 2 deletions tests/links_tests/model_tests/vgg_tests/test_vgg16.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest

import copy
import numpy as np

import chainer
Expand All @@ -20,7 +21,7 @@
class TestVGG16Call(unittest.TestCase):

def setUp(self):
params = VGG16.preset_params['imagenet'].copy()
params = copy.deepcopy(VGG16.preset_params['imagenet'])
params['n_class'] = self.n_class
self.link = VGG16(
pretrained_model=None, initialW=Zero(), **params)
Expand Down Expand Up @@ -60,7 +61,7 @@ class TestVGG16Pretrained(unittest.TestCase):

@attr.slow
def test_pretrained(self):
params = VGG16.preset_params[self.pretrained_model].copy()
params = copy.deepcopy(VGG16.preset_params[self.pretrained_model])
params['n_class'] = self.n_class
params['mean'] = self.mean

Expand Down
5 changes: 3 additions & 2 deletions tests/links_tests/model_tests/yolo_tests/test_yolo_v2.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
import numpy as np
import unittest

Expand All @@ -14,7 +15,7 @@
class TestYOLOv2(unittest.TestCase):

def setUp(self):
params = YOLOv2.preset_params['voc'].copy()
params = copy.deepcopy(YOLOv2.preset_params['voc'])
params['n_fg_class'] = self.n_fg_class
self.link = YOLOv2(**params)
self.insize = 416
Expand Down Expand Up @@ -58,7 +59,7 @@ class TestYOLOv2Pretrained(unittest.TestCase):

@attr.slow
def test_pretrained(self):
params = YOLOv2.preset_params['voc'].copy()
params = copy.deepcopy(YOLOv2.preset_params['voc'])
params['n_fg_class'] = self.n_fg_class

if self.pretrained_model == 'voc0712':
Expand Down
5 changes: 3 additions & 2 deletions tests/links_tests/model_tests/yolo_tests/test_yolo_v3.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
import numpy as np
import unittest

Expand All @@ -14,7 +15,7 @@
class TestYOLOv3(unittest.TestCase):

def setUp(self):
params = YOLOv3.preset_params['voc'].copy()
params = copy.deepcopy(YOLOv3.preset_params['voc'])
params['n_fg_class'] = self.n_fg_class
self.link = YOLOv3(**params)
self.insize = 416
Expand Down Expand Up @@ -58,7 +59,7 @@ class TestYOLOv3Pretrained(unittest.TestCase):

@attr.slow
def test_pretrained(self):
params = YOLOv3.preset_params['voc'].copy()
params = copy.deepcopy(YOLOv3.preset_params['voc'])
params['n_fg_class'] = self.n_fg_class

if self.pretrained_model == 'voc0712':
Expand Down

0 comments on commit b914fe8

Please sign in to comment.