1
- @testset " AlexNet" begin
1
+ @testitem " AlexNet" setup = [TestModels] begin
2
2
model = AlexNet ()
3
3
@test size (model (x_256)) == (1000 , 1 )
4
4
@test_throws ArgumentError AlexNet (pretrain = true )
5
5
@test gradtest (model, x_256)
6
6
_gc ()
7
7
end
8
8
9
- @testset " VGG" begin
9
+ @testitem " VGG" setup = [TestModels] begin
10
10
@testset " VGG($sz , batchnorm=$bn )" for sz in [11 , 13 , 16 , 19 ], bn in [true , false ]
11
11
m = VGG (sz, batchnorm = bn)
12
12
@test size (m (x_224)) == (1000 , 1 )
20
20
end
21
21
end
22
22
23
- @testset " ResNet" begin
23
+ @testitem " ResNet" setup = [TestModels] begin
24
24
# Tests for pretrained ResNets
25
25
@testset " ResNet($sz )" for sz in [18 , 34 , 50 , 101 , 152 ]
26
26
m = ResNet (sz)
58
58
end
59
59
60
60
61
- @testset " WideResNet" begin
61
+ @testitem " WideResNet" setup = [TestModels] begin
62
62
@testset " WideResNet($sz )" for sz in [50 , 101 ]
63
63
m = WideResNet (sz)
64
64
@test size (m (x_224)) == (1000 , 1 )
72
72
end
73
73
end
74
74
75
- @testset " ResNeXt" begin
75
+ @testitem " ResNeXt" setup = [TestModels] begin
76
76
@testset for depth in [50 , 101 , 152 ]
77
77
@testset for cardinality in [32 , 64 ]
78
78
@testset for base_width in [4 , 8 ]
90
90
end
91
91
end
92
92
93
- @testset " SEResNet" begin
93
+ @testitem " SEResNet" setup = [TestModels] begin
94
94
@testset for depth in [18 , 34 , 50 , 101 , 152 ]
95
95
m = SEResNet (depth)
96
96
@test size (m (x_224)) == (1000 , 1 )
104
104
end
105
105
end
106
106
107
- @testset " SEResNeXt" begin
107
+ @testitem " SEResNeXt" setup = [TestModels] begin
108
108
@testset for depth in [50 , 101 , 152 ]
109
109
@testset for cardinality in [32 , 64 ]
110
110
@testset for base_width in [4 , 8 ]
122
122
end
123
123
end
124
124
125
- @testset " Res2Net" begin
125
+ @testitem " Res2Net" setup = [TestModels] begin
126
126
@testset for (base_width, scale) in [(26 , 4 ), (48 , 2 ), (14 , 8 ), (26 , 6 ), (26 , 8 )]
127
127
m = Res2Net (50 ; base_width, scale)
128
128
@test size (m (x_224)) == (1000 , 1 )
147
147
end
148
148
end
149
149
150
- @testset " Res2NeXt" begin
150
+ @testitem " Res2NeXt" setup = [TestModels] begin
151
151
@testset for depth in [50 , 101 ]
152
152
m = Res2NeXt (depth)
153
153
@test size (m (x_224)) == (1000 , 1 )
161
161
end
162
162
end
163
163
164
- @testset " EfficientNet" begin
164
+ @testitem " EfficientNet" setup = [TestModels] begin
165
165
@testset " EfficientNet($config )" for config in [:b0 , :b1 , :b2 , :b3 , :b4 , :b5 ,] # :b6, :b7, :b8]
166
166
# preferred image resolution scaling
167
167
r = Metalhead. EFFICIENTNET_GLOBAL_CONFIGS[config][1 ]
178
178
end
179
179
end
180
180
181
- @testset " EfficientNetv2" begin
181
+ @testitem " EfficientNetv2" setup = [TestModels] begin
182
182
@testset for config in [:small , :medium , :large ] # :xlarge]
183
183
m = EfficientNetv2 (config)
184
184
@test size (m (x_224)) == (1000 , 1 )
192
192
end
193
193
end
194
194
195
- @testset " GoogLeNet" begin
195
+ @testitem " GoogLeNet" setup = [TestModels] begin
196
196
@testset for bn in [true , false ]
197
197
m = GoogLeNet (batchnorm = bn)
198
198
@test size (m (x_224)) == (1000 , 1 )
@@ -206,55 +206,22 @@ end
206
206
end
207
207
end
208
208
209
- @testset " Inception" begin
209
+ @testitem " Inception" setup = [TestModels] begin
210
210
x_299 = rand (Float32, 299 , 299 , 3 , 2 )
211
- @testset " Inceptionv3 " begin
212
- m = Inceptionv3 ()
211
+ @testset " $Model " for Model in [Inceptionv3, Inceptionv4, InceptionResNetv2, Xception]
212
+ m = Model ()
213
213
@test size (m (x_299)) == (1000 , 2 )
214
- if Inceptionv3 in PRETRAINED_MODELS
215
- @test acctest (Inceptionv3 (pretrain = true ))
214
+ if Model in PRETRAINED_MODELS
215
+ @test acctest (Model (pretrain = true ))
216
216
else
217
- @test_throws ArgumentError Inceptionv3 (pretrain = true )
218
- end
219
- @test gradtest (m, x_299)
220
- end
221
- _gc ()
222
- @testset " Inceptionv4" begin
223
- m = Inceptionv4 ()
224
- @test size (m (x_299)) == (1000 , 2 )
225
- if Inceptionv4 in PRETRAINED_MODELS
226
- @test acctest (Inceptionv4 (pretrain = true ))
227
- else
228
- @test_throws ArgumentError Inceptionv4 (pretrain = true )
229
- end
230
- @test gradtest (m, x_299)
231
- end
232
- _gc ()
233
- @testset " InceptionResNetv2" begin
234
- m = InceptionResNetv2 ()
235
- @test size (m (x_299)) == (1000 , 2 )
236
- if InceptionResNetv2 in PRETRAINED_MODELS
237
- @test acctest (InceptionResNetv2 (pretrain = true ))
238
- else
239
- @test_throws ArgumentError InceptionResNetv2 (pretrain = true )
240
- end
241
- @test gradtest (m, x_299)
242
- end
243
- _gc ()
244
- @testset " Xception" begin
245
- m = Xception ()
246
- @test size (m (x_299)) == (1000 , 2 )
247
- if Xception in PRETRAINED_MODELS
248
- @test acctest (Xception (pretrain = true ))
249
- else
250
- @test_throws ArgumentError Xception (pretrain = true )
217
+ @test_throws ArgumentError Model (pretrain = true )
251
218
end
252
219
@test gradtest (m, x_299)
220
+ _gc ()
253
221
end
254
- _gc ()
255
222
end
256
223
257
- @testset " SqueezeNet" begin
224
+ @testitem " SqueezeNet" setup = [TestModels] begin
258
225
m = SqueezeNet ()
259
226
@test size (m (x_224)) == (1000 , 1 )
260
227
if SqueezeNet in PRETRAINED_MODELS
266
233
_gc ()
267
234
end
268
235
269
- @testset " DenseNet" begin
236
+ @testitem " DenseNet" setup = [TestModels] begin
270
237
@testset for sz in [121 , 161 , 169 , 201 ]
271
238
m = DenseNet (sz)
272
239
@test size (m (x_224)) == (1000 , 1 )
280
247
end
281
248
end
282
249
283
- @testset " MobileNets (width = $width_mult )" for width_mult in [0.5 , 0.75 , 1 , 1.3 ]
284
- @testset " MobileNetv1" begin
250
+ @testsetup module TestMobileNets
251
+ export WIDTH_MULTS
252
+ const WIDTH_MULTS = [0.5 , 0.75 , 1.0 , 1.3 ]
253
+ end
254
+
255
+ @testitem " MobileNetsV1" setup= [TestModels, TestMobileNets] begin
256
+ @testset for width_mult in WIDTH_MULTS
285
257
m = MobileNetv1 (width_mult)
286
258
@test size (m (x_224)) == (1000 , 1 )
287
259
if (MobileNetv1, width_mult) in PRETRAINED_MODELS
290
262
@test_throws ArgumentError MobileNetv1 (pretrain = true )
291
263
end
292
264
@test gradtest (m, x_224)
265
+ _gc ()
293
266
end
294
- _gc ()
295
- @testset " MobileNetv2" begin
267
+ end
268
+
269
+ @testitem " MobileNetv2" setup= [TestModels, TestMobileNets] begin
270
+ @testset for width_mult in WIDTH_MULTS
296
271
m = MobileNetv2 (width_mult)
297
272
@test size (m (x_224)) == (1000 , 1 )
298
273
if (MobileNetv2, width_mult) in PRETRAINED_MODELS
302
277
end
303
278
@test gradtest (m, x_224)
304
279
end
305
- _gc ()
306
- @testset " MobileNetv3" verbose = true begin
280
+ end
281
+
282
+
283
+ @testitem " MobileNetv3" setup= [TestModels, TestMobileNets] begin
284
+ @testset for width_mult in WIDTH_MULTS
307
285
@testset for config in [:small , :large ]
308
286
m = MobileNetv3 (config; width_mult)
309
287
@test size (m (x_224)) == (1000 , 1 )
316
294
_gc ()
317
295
end
318
296
end
319
- @testset " MNASNet" verbose = true begin
297
+ end
298
+
299
+ @testitem " MNASNet" setup= [TestModels, TestMobileNets] begin
300
+ @testset for width in WIDTH_MULTS
320
301
@testset for config in [:A1 , :B1 ]
321
302
m = MNASNet (config; width_mult)
322
303
@test size (m (x_224)) == (1000 , 1 )
331
312
end
332
313
end
333
314
334
- @testset " ConvNeXt" verbose = true begin
315
+ @testitem " ConvNeXt" setup = [TestModels] begin
335
316
@testset for config in [:small , :base , :large , :tiny , :xlarge ]
336
317
m = ConvNeXt (config)
337
318
@test size (m (x_224)) == (1000 , 1 )
340
321
end
341
322
end
342
323
343
- @testset " ConvMixer" verbose = true begin
324
+ @testitem " ConvMixer" setup = [TestModels] begin
344
325
@testset for config in [:small , :base , :large ]
345
326
m = ConvMixer (config)
346
327
@test size (m (x_224)) == (1000 , 1 )
349
330
end
350
331
end
351
332
352
- @testset " UNet" begin
333
+ @testitem " UNet" setup = [TestModels] begin
353
334
encoder = Metalhead. backbone (ResNet (18 ))
354
335
model = UNet ((256 , 256 ), 3 , 10 , encoder)
355
336
@test size (model (x_256)) == (256 , 256 , 10 , 1 )
0 commit comments