This repository has been archived by the owner on Jun 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
test_feature_detection.py
83 lines (72 loc) · 2.15 KB
/
test_feature_detection.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
"""Unit test related to the feature detection model
"""
from keras.models import Model
from deeposlandia.feature_detection import FeatureDetectionNetwork
def test_simple_network_architecture(
shapes_image_size, nb_channels, shapes_nb_labels
):
"""Test a simple feature detection network
"""
net = FeatureDetectionNetwork(
"fd_test",
image_size=shapes_image_size,
nb_channels=nb_channels,
nb_labels=shapes_nb_labels,
)
m = Model(net.X, net.Y)
input_shape = m.input_shape
output_shape = m.output_shape
assert len(input_shape) == 4
assert input_shape[1:] == (
shapes_image_size,
shapes_image_size,
nb_channels,
)
assert len(output_shape) == 2
assert output_shape[1] == shapes_nb_labels
def test_vgg16_network_architecture(
mapillary_image_size, nb_channels, mapillary_nb_labels
):
"""Test a VGG16-inspired feature detection network
"""
net = FeatureDetectionNetwork(
"fd_test",
image_size=mapillary_image_size,
nb_channels=nb_channels,
nb_labels=mapillary_nb_labels,
architecture="vgg",
)
m = Model(net.X, net.Y)
input_shape = m.input_shape
output_shape = m.output_shape
assert len(input_shape) == 4
assert input_shape[1:] == (
mapillary_image_size,
mapillary_image_size,
nb_channels,
)
assert len(output_shape) == 2
assert output_shape[1] == mapillary_nb_labels
def test_inception_network_architecture(
mapillary_image_size, nb_channels, mapillary_nb_labels
):
"""Test a Inception-inspired feature detection network
"""
net = FeatureDetectionNetwork(
"fd_test",
image_size=mapillary_image_size,
nb_channels=nb_channels,
nb_labels=mapillary_nb_labels,
architecture="inception",
)
m = Model(net.X, net.Y)
input_shape = m.input_shape
output_shape = m.output_shape
assert len(input_shape) == 4
assert input_shape[1:] == (
mapillary_image_size,
mapillary_image_size,
nb_channels,
)
assert len(output_shape) == 2
assert output_shape[1] == mapillary_nb_labels