-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_datasets.py
116 lines (85 loc) · 3.42 KB
/
test_datasets.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import pytest
import numpy as np
def test_ucfcrime_size(ucfcrime_dataset):
# testing for number of videos in _debug mode
assert ucfcrime_dataset.num_videos == 2
# testing for number of clips
assert len(ucfcrime_dataset) == 2926
def test_xdviolence_size(xdviolence_dataset):
# testing for number of videos in _debug mode
assert xdviolence_dataset.num_videos == 2
# testing for number of clips
assert len(xdviolence_dataset) == 4899
def test_avenue_size(avenue_dataset):
# testing for number of videos in _debug mode
assert avenue_dataset.num_videos == 2
# testing for number of clips
assert len(avenue_dataset) == 2620
def test_shanghaitech_size(shanghaitech_dataset):
# testing for number of videos in _debug mode
assert shanghaitech_dataset.num_videos == 2
# testing for number of clips
assert len(shanghaitech_dataset) == 249
@pytest.mark.parametrize("idx", [1, 10])
def test_ucfcrime_sample(idx, ucfcrime_dataset):
video, label, temporal_label = ucfcrime_dataset[idx]
# checking sample: # of frames
assert video.shape[0] == 16
# checking sample: channelis last
assert video.shape[-1] == 3
# testing temporal labels
assert video.shape[0] == temporal_label.shape[0]
@pytest.mark.parametrize("idx", [1, 10])
def test_xdviolence_sample(idx, xdviolence_dataset):
video, label, temporal_label = xdviolence_dataset[idx]
# checking sample: # of frames
assert video.shape[0] == 16
# checking sample: channelis last
assert video.shape[-1] == 3
# testing temporal labels
assert video.shape[0] == temporal_label.shape[0]
@pytest.mark.parametrize("idx", [1, 10])
def test_avenue_sample(idx, avenue_dataset):
video, label, temporal_label = avenue_dataset[idx]
# checking sample: # of frames
assert video.shape[0] == 16
# checking sample: channelis last
assert video.shape[-1] == 3
# testing temporal labels
assert video.shape[0] == temporal_label.shape[0]
@pytest.mark.parametrize("idx", [1, 10])
def test_shanghaitech_sample(idx, shanghaitech_dataset):
video, label, temporal_label = shanghaitech_dataset[idx]
# checking sample: # of frames
assert video.shape[0] == 16
# checking sample: channelis last
assert video.shape[-1] == 3
# testing temporal labels
assert video.shape[0] == temporal_label.shape[0]
@pytest.mark.parametrize("idx", [1, 10])
def test_ucfcrime_labels(idx, ucfcrime_dataset):
video, label, temporal_label = ucfcrime_dataset[idx]
# check video labels
# label corresponds to the whole video label, NOT sub-clip
assert label == 1.
# check temporal labels
assert np.sum(temporal_label) == 0.
@pytest.mark.parametrize("idx", [1, 10])
def test_xdviolence_labels(idx, xdviolence_dataset):
video, label, temporal_label = xdviolence_dataset[idx]
# check video labels
assert label == 0.
# check temporal labels
assert np.sum(temporal_label) == 0.
@pytest.mark.parametrize("idx", [1, 10])
def test_avenue_labels(idx, avenue_dataset):
video, label, temporal_label = avenue_dataset[idx]
# check temporal labels
assert np.sum(temporal_label) == 0.
@pytest.mark.parametrize("idx", [1, 10])
def test_shanghaitech_labels(idx, shanghaitech_dataset):
video, label, temporal_label = shanghaitech_dataset[idx]
# check video labels
assert label == 0.
# check temporal labels
assert np.sum(temporal_label) == 0.