|
39 | 39 | ) |
40 | 40 | from compressai.zoo import ( |
41 | 41 | bmshj2018_factorized, |
| 42 | + bmshj2018_factorized_relu, |
42 | 43 | bmshj2018_hyperprior, |
43 | 44 | cheng2020_anchor, |
44 | 45 | cheng2020_attn, |
@@ -98,6 +99,33 @@ def test_pretrained(self, metric): |
98 | 99 | assert net.state_dict()["g_a.6.weight"].size(0) == 320 |
99 | 100 |
|
100 | 101 |
|
| 102 | +class TestBmshj2018FactorizedReLU: |
| 103 | + def test_params(self): |
| 104 | + for i in range(1, 6): |
| 105 | + net = bmshj2018_factorized_relu(i, metric="mse") |
| 106 | + assert isinstance(net, FactorizedPrior) |
| 107 | + assert net.state_dict()["g_a.0.weight"].size(0) == 128 |
| 108 | + assert net.state_dict()["g_a.6.weight"].size(0) == 192 |
| 109 | + |
| 110 | + for i in range(6, 9): |
| 111 | + net = bmshj2018_factorized_relu(i, metric="mse") |
| 112 | + assert isinstance(net, FactorizedPrior) |
| 113 | + assert net.state_dict()["g_a.0.weight"].size(0) == 192 |
| 114 | + |
| 115 | + def test_invalid_params(self): |
| 116 | + with pytest.raises(ValueError): |
| 117 | + bmshj2018_factorized_relu(-1) |
| 118 | + |
| 119 | + with pytest.raises(ValueError): |
| 120 | + bmshj2018_factorized_relu(10) |
| 121 | + |
| 122 | + with pytest.raises(ValueError): |
| 123 | + bmshj2018_factorized_relu(10, metric="ssim") |
| 124 | + |
| 125 | + with pytest.raises(ValueError): |
| 126 | + bmshj2018_factorized_relu(1, metric="ssim") |
| 127 | + |
| 128 | + |
101 | 129 | class TestBmshj2018Hyperprior: |
102 | 130 | def test_params(self): |
103 | 131 | for i in range(1, 6): |
@@ -131,12 +159,12 @@ def test_invalid_params(self): |
131 | 159 | def test_pretrained(self, metric): |
132 | 160 | # test we can load the correct models from the urls |
133 | 161 | for i in range(1, 6): |
134 | | - net = bmshj2018_factorized(i, metric=metric, pretrained=True) |
| 162 | + net = bmshj2018_hyperprior(i, metric=metric, pretrained=True) |
135 | 163 | assert net.state_dict()["g_a.0.weight"].size(0) == 128 |
136 | 164 | assert net.state_dict()["g_a.6.weight"].size(0) == 192 |
137 | 165 |
|
138 | 166 | for i in range(6, 9): |
139 | | - net = bmshj2018_factorized(i, metric=metric, pretrained=True) |
| 167 | + net = bmshj2018_hyperprior(i, metric=metric, pretrained=True) |
140 | 168 | assert net.state_dict()["g_a.0.weight"].size(0) == 192 |
141 | 169 | assert net.state_dict()["g_a.6.weight"].size(0) == 320 |
142 | 170 |
|
|
0 commit comments