experiments.rst 12.1 KB
Newer Older
André Anjos's avatar
André Anjos committed
1
.. vim: set fileencoding=utf-8 :
André Anjos's avatar
André Anjos committed
2

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
.. Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/          ..
.. Contact: beat.support@idiap.ch                                             ..
..                                                                            ..
.. This file is part of the beat.cmdline module of the BEAT platform.         ..
..                                                                            ..
.. Commercial License Usage                                                   ..
.. Licensees holding valid commercial BEAT licenses may use this file in      ..
.. accordance with the terms contained in a written agreement between you     ..
.. and Idiap. For further information contact tto@idiap.ch                    ..
..                                                                            ..
.. Alternatively, this file may be used under the terms of the GNU Affero     ..
.. Public License version 3 as published by the Free Software and appearing   ..
.. in the file LICENSE.AGPL included in the packaging of this file.           ..
.. The BEAT platform is distributed in the hope that it will be useful, but   ..
.. WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ..
.. or FITNESS FOR A PARTICULAR PURPOSE.                                       ..
..                                                                            ..
.. You should have received a copy of the GNU Affero Public License along     ..
.. with the BEAT platform. If not, see http://www.gnu.org/licenses/.          ..
André Anjos's avatar
André Anjos committed
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366


.. _beat-core-experiments-cmdline:

Experiments
-----------

The BEAT command-line utility called ``beat`` can perform a variety of actions
concerning experiments. These actions are grouped in two sets:

  * local: Local actions allow the user to act on locally installed objects
  * remote: Actions on the remote web platform

Once you have setup your prefix directory as explained in
:ref:`beat-cmdline-configuration`, you're ready to start configuring new
experiments.

The commands available for experiments are:

.. command-output:: ./bin/beat experiments --help
   :cwd: ..


.. _beat-core-experiments-running:

How to run an experiment?
.........................

The ``run_toolchain.py`` script can be used to perform the experiment defined
in a toolchain. It is the ideal way to debug an algorithm, since this script
doesn't try to do any advanced trick like the Scheduler (multi-processing,
optimizations, sandboxing, ...).

For example, we execute a simple toolchain with two processing blocks (found in
``src/beat.core/beat/core/test/toolchains/integers_addition2.json``):

.. code-block:: sh

    $ ./bin/run_toolchain.py --prefix=src/beat.core/beat/core/test/ integers_addition2
    Processing block 'addition1'...
        Algorithm: sum
        Inputs:
            - a (single_integer): beat/src/beat.core/beat/core/test/databases/integers/output1.data
            - b (single_integer): beat/src/beat.core/beat/core/test/databases/integers/output2.data
        Outputs:
            - sum (single_integer): beat/src/beat.core/beat/core/test/cache/addition1/sum.data

    Processing block 'addition2'...
        Algorithm: sum
        Inputs:
            - a (single_integer): beat/src/beat.core/beat/core/test/cache/addition1/sum.data
            - b (single_integer): beat/src/beat.core/beat/core/test/databases/integers/output3.data
        Outputs:
            - sum (single_integer): beat/src/beat.core/beat/core/test/cache/addition2/sum.data

    DONE

    Results available at:
        - addition2.sum: beat/src/beat.core/beat/core/test/cache/addition2/sum.data

Here, the ``--prefix`` option is used to tell the scripts where all our data
formats, toolchains and algorithms are located, and ``integers_addition2`` is
the name of the toolchain we want to check (note that we don't add the
``.json`` extension, as this is the name of the toolchain, not the filename!).

This script displays for each block the files containing the data to use as
input, and the files generated by the outputs of the block.

By default, files are generated in binary format, but you can force them to be
in a more readable JSON format with the ``--json`` flag:

.. code-block:: sh

    $ ./bin/run_toolchain.py --prefix=src/beat.core/beat/core/test/ --json integers_addition2

The default behavior is to not regenerate data files already present in the
cache. You can force the script to not take the content of the cache into
account with the ``--force`` flag:

.. code-block:: sh

    $ ./bin/run_toolchain.py --prefix=src/beat.core/beat/core/test/ --force integers_addition2


.. _beat-core-experiments-displaydata:

How to examine the content of a data file?
..........................................

The ``display_data.py`` script can be used to examine the content of a data
file generated by the execution of a toolchain.

For example, we look at the content of one of the data file used by the tests
of beat.core (found in
``src/beat.core/beat/core/test/data/single_integer.data``):

.. code-block:: sh

    $ ./bin/display_data.py --prefix=src/beat.core/beat/core/test data/single_integer_delayed.data
    Data format: single_integer
    ----------------------------------------------
    Indexes: 0-1
    {
        "value": 0
    }
    ----------------------------------------------
    Indexes: 2-3
    {
        "value": 1
    }
    ----------------------------------------------
    Indexes: 4-5
    {
        "value": 2
    }
    ----------------------------------------------
    Indexes: 6-7
    {
        "value": 3
    }
    ----------------------------------------------
    Indexes: 8-9
    {
        "value": 4
    }
    ----------------------------------------------
    Indexes: 10-11
    {
        "value": 5
    }
    ----------------------------------------------
    Indexes: 12-13
    {
        "value": 6
    }
    ----------------------------------------------
    Indexes: 14-15
    {
        "value": 7
    }
    ----------------------------------------------
    Indexes: 16-17
    {
        "value": 8
    }
    ----------------------------------------------
    Indexes: 18-19
    {
        "value": 9
    }

The script tells us that the data correspond to the data format
``single_integer``, and displays each entry (with the indexes it correspond to)
in a JSON representation.


.. _beat-core-experiments-example:

Putting it all together: a complete example
...........................................

.. _beat-core-experiments-example-figure:
.. figure:: img/toolchain-example.*

   A complete toolchain that train and test a face detector

The following example describes the toolchain visible at :num:`figure
#beat-core-toolchains-example-figure`, a complete toolchain that:

  #. train a face detector on one set of images (*beat_face_dataset_train*)
  #. validate it on another set of images (*beat_face_dataset_validation*)
  #. test it on a third set of images (*beat_face_dataset_test*)

.. note::

   This toolchain is still not considered as an executable one by the platform,
   since it contains no mention of the algorithms that must be used in each
   processing block.

.. code-block:: json

    {
        "databases": [ {
                "name": "beat_face_dataset_train",
                "outputs": {
                    "images": "image/rgb",
                    "faces": "coordinates_list"
                }
            },
            {
                "name": "beat_face_dataset_validation",
                "outputs": {
                    "images": "image/rgb",
                    "faces": "coordinates_list"
                }
            },
            {
                "name": "beat_face_dataset_test",
                "outputs": {
                    "images": "image/rgb",
                    "faces": "coordinates_list"
                }
            }
        ],
        "blocks": [{
                "name": "features_extractor_train",
                "inputs": {
                    "images": "images/rgb"
                },
                "outputs": {
                    "features": "array/float"
                }
            },
            {
                "name": "face_model_builder",
                "inputs": {
                    "features": "array/float",
                    "faces": "coordinates_list"
                },
                "outputs": {
                    "model": "face_model"
                }
            },
            {
                "name": "features_extractor_validation",
                "inputs": {
                    "images": "images/rgb"
                },
                "outputs": {
                    "features": "array/float"
                }
            },
            {
                "name": "face_detector_validation",
                "inputs": {
                    "model": "face_model",
                    "features": "array/float"
                },
                "outputs": {
                    "faces": "coordinates_list"
                }
            },
            {
                "name": "thresholder",
                "inputs": {
                    "detected_faces": "coordinates_list",
                    "labelled_faces": "coordinates_list"
                },
                "outputs": {
                    "threshold": "float"
                }
            },
            {
                "name": "features_extractor_test",
                "inputs": {
                    "images": "images/rgb"
                },
                "outputs": {
                    "features": "array/float"
                }
            },
            {
                "name": "face_detector_test",
                "inputs": {
                    "model": "face_model",
                    "features": "array/float"
                },
                "outputs": {
                    "faces": "coordinates_list"
                }
            },
            {
                "name": "evaluator",
                "inputs": {
                    "threshold": "float",
                    "detected_faces": "coordinates_list",
                    "labelled_faces": "coordinates_list"
                },
                "outputs": {
                    "score": "float"
                }
            }
        ],
        "connections": [{
                "from": "beat_face_dataset_train.images",
                "to": "features_extractor_train.images"
            },
            {
                "from": "features_extractor_train.features",
                "to": "face_model_builder.features"
            },
            {
                "from": "beat_face_dataset_train.faces",
                "to": "face_model_builder.faces"
            },
            {
                "from": "beat_face_dataset_validation.images",
                "to": "features_extractor_validation.images"
            },
            {
                "from": "face_model_builder.model",
                "to": "face_detector_validation.model"
            },
            {
                "from": "features_extractor_validation.features",
                "to": "face_detector_validation.features"
            },
            {
                "from": "face_detector_validation.faces",
                "to": "thresholder.detected_faces"
            },
            {
                "from": "beat_face_dataset_validation.faces",
                "to": "thresholder.labelled_faces"
            },
            {
                "from": "beat_face_dataset_test.images",
                "to": "features_extractor_test.images"
            },
            {
                "from": "features_extractor_test.features",
                "to": "face_detector_test.features"
            },
            {
                "from": "face_model_builder.model",
                "to": "face_detector_test.model"
            },
            {
                "from": "thresholder.threshold",
                "to": "evaluator.threshold"
            },
            {
                "from": "face_detector_test.faces",
                "to": "evaluator.detected_faces"
            },
            {
                "from": "beat_face_dataset_test.faces",
                "to": "evaluator.labelled_faces"
            }
        ],
        "results": [
            "thresholder.threshold",
            "evaluator.score"
        ]
    }