Commit e2da2801 authored by Guillaume HEUSCH's avatar Guillaume HEUSCH
Browse files

[protocols] changed the code so as to have protocol and subset(s) as...

[protocols] changed the code so as to have protocol and subset(s) as arguments, add the protocol and data sets txt files
parent c9184fb5
......@@ -22,47 +22,49 @@ class Database(object):
self.metadata = [row for row in reader]
def objects(self, protocol=None):
def objects(self, protocol='all', subset=None):
"""Returns a list of unique :py:class:`.File` objects for the specific
query by the user.
Parameters:
protocol (str, optional): If set, can take the value of 'cvpr14',
which subselects samples used by Li et al. on their CVPR'14 paper for
heart-rate estimation.
protocol (str, optional): If set, can take the value of either 'cvpr14' or 'all'.
'cvpr14' subselects samples used by Li et al. on their CVPR'14 paper for
heart-rate estimation. If 'all' is set, the complete database is selected.
subset (str, optional): If set, it could be either 'train', 'dev' or 'test'
or a combination of them (i.e. a list). If not set (default),
the files from all these sets are retrieved for the 'all' protocol.
Note that for 'cvpr14' protocol, this has no effect, since no training,
development and test set have been defined in this case.
Returns: A list of :py:class:`File` objects.
"""
if protocol in ('cvpr14',):
d = resource_filename(__name__, os.path.join('data', 'li_samples_cvpr14.txt'))
with open(d, 'rt') as f: sessions = f.read().split()
return [File(**k) for k in self.metadata if k['basedir'] in sessions]
elif protocol in ('train',):
d = resource_filename(__name__, os.path.join('data', 'train.txt'))
d = resource_filename(__name__, os.path.join('protocols/cvpr14', 'li_samples_cvpr14.txt'))
with open(d, 'rt') as f: sessions = f.read().split()
return [File(**k) for k in self.metadata if k['basedir'] in sessions]
elif protocol in ('dev',):
d = resource_filename(__name__, os.path.join('data', 'dev.txt'))
with open(d, 'rt') as f: sessions = f.read().split()
return [File(**k) for k in self.metadata if k['basedir'] in sessions]
elif protocol in ('test',):
d = resource_filename(__name__, os.path.join('data', 'test.txt'))
with open(d, 'rt') as f: sessions = f.read().split()
return [File(**k) for k in self.metadata if k['basedir'] in sessions]
elif protocol in ('traindev',):
d = resource_filename(__name__, os.path.join('data', 'traindev.txt'))
with open(d, 'rt') as f: sessions = f.read().split()
return [File(**k) for k in self.metadata if k['basedir'] in sessions]
elif protocol is not None:
raise RuntimeError('Protocol should be either "train", "dev", "traindev", "test", "cvpr14" or not set. The value %s is not valid' % protocol)
if protocol in ('all'):
return [File(**k) for k in self.metadata]
if 'None' in subset:
return [File(**k) for k in self.metadata]
else:
files = []
if 'train' in subset:
d = resource_filename(__name__, os.path.join('protocols/all', 'train.txt'))
with open(d, 'rt') as f: sessions = f.read().split()
files += [File(**k) for k in self.metadata if k['basedir'] in sessions]
if 'dev' in subset:
d = resource_filename(__name__, os.path.join('protocols/all', 'dev.txt'))
with open(d, 'rt') as f: sessions = f.read().split()
files += [File(**k) for k in self.metadata if k['basedir'] in sessions]
if 'test' in subset:
d = resource_filename(__name__, os.path.join('protocols/all', 'test.txt'))
with open(d, 'rt') as f: sessions = f.read().split()
files += [File(**k) for k in self.metadata if k['basedir'] in sessions]
return files
Sessions/1546
Sessions/1476
Sessions/1719
Sessions/2526
Sessions/665
Sessions/1811
Sessions/715
Sessions/2542
Sessions/2836
Sessions/1735
Sessions/2093
Sessions/3368
Sessions/2365
Sessions/2148
Sessions/2124
Sessions/2768
Sessions/3331
Sessions/2555
Sessions/2743
Sessions/2767
Sessions/2749
Sessions/1694
Sessions/2577
Sessions/3326
Sessions/1795
Sessions/2197
Sessions/1474
Sessions/2131
Sessions/666
Sessions/2762
Sessions/269
Sessions/381
Sessions/2799
Sessions/370
Sessions/2154
Sessions/2382
Sessions/2143
Sessions/1705
Sessions/2508
Sessions/2500
Sessions/2557
Sessions/2466
Sessions/1745
Sessions/3349
Sessions/3336
Sessions/2444
Sessions/1696
Sessions/1541
Sessions/1510
Sessions/2741
Sessions/2366
Sessions/2085
Sessions/2190
Sessions/2846
Sessions/1817
Sessions/2385
Sessions/2372
Sessions/2104
Sessions/672
Sessions/741
Sessions/2094
Sessions/308
Sessions/1698
Sessions/2757
Sessions/678
Sessions/3363
Sessions/2091
Sessions/767
Sessions/744
Sessions/2740
Sessions/2524
Sessions/3347
Sessions/1801
Sessions/2409
Sessions/373
Sessions/2183
Sessions/1473
Sessions/2516
Sessions/1481
Sessions/686
Sessions/2804
Sessions/700
Sessions/2572
Sessions/2130
Sessions/1764
Sessions/3348
Sessions/2378
Sessions/2449
Sessions/2129
Sessions/323
Sessions/758
Sessions/1797
Sessions/2127
Sessions/2367
Sessions/2112
Sessions/1755
Sessions/2462
Sessions/2186
Sessions/2579
Sessions/2779
Sessions/306
Sessions/2174
Sessions/2357
Sessions/2525
Sessions/2195
Sessions/729
Sessions/1715
Sessions/3314
Sessions/2083
Sessions/1722
Sessions/2849
Sessions/1518
Sessions/2424
Sessions/1767
Sessions/683
Sessions/3318
Sessions/2564
Sessions/2780
Sessions/1548
Sessions/2789
Sessions/2837
Sessions/2471
Sessions/774
Sessions/2576
Sessions/2369
Sessions/367
Sessions/309
Sessions/685
Sessions/2797
Sessions/329
Sessions/2412
Sessions/2193
Sessions/3302
Sessions/2375
Sessions/2745
Sessions/713
Sessions/2445
Sessions/3354
Sessions/2514
Sessions/1787
Sessions/733
Sessions/2778
Sessions/1768
Sessions/2084
Sessions/354
Sessions/761
Sessions/2442
Sessions/2414
Sessions/2430
Sessions/3322
Sessions/2360
Sessions/3376
Sessions/2454
Sessions/2171
Sessions/2751
Sessions/1699
Sessions/2755
Sessions/2582
Sessions/2811
Sessions/2783
Sessions/1781
Sessions/2354
Sessions/1765
Sessions/2549
Sessions/2101
Sessions/2496
Sessions/2364
Sessions/766
Sessions/727
Sessions/290
Sessions/316
Sessions/2145
Sessions/765
Sessions/705
Sessions/775
Sessions/294
Sessions/2415
Sessions/3369
Sessions/3378
Sessions/753
Sessions/2817
Sessions/2567
Sessions/768
Sessions/2532
Sessions/3332
Sessions/3374
Sessions/1508
Sessions/1488
Sessions/2505
Sessions/2764
Sessions/2597
Sessions/2099
Sessions/1549
Sessions/736
Sessions/2098
Sessions/2102
Sessions/1502
Sessions/3371
Sessions/2826
Sessions/1552
Sessions/2494
Sessions/2732
Sessions/2513
Sessions/2392
Sessions/2477
Sessions/2815
Sessions/2770
Sessions/2205
Sessions/655
Sessions/2418
Sessions/2158
Sessions/695
Sessions/3364
Sessions/2486
Sessions/708
Sessions/764
Sessions/334
Sessions/3333
Sessions/1535
Sessions/1498
Sessions/771
Sessions/690
Sessions/2735
Sessions/3311
Sessions/2482
Sessions/724
Sessions/2485
Sessions/2593
Sessions/1702
Sessions/3304
Sessions/706
Sessions/716
Sessions/1714
Sessions/317
Sessions/2856
Sessions/320
Sessions/1707
Sessions/3340
Sessions/657
Sessions/1736
Sessions/336
Sessions/2474
Sessions/2368
Sessions/1520
Sessions/2452
Sessions/748
Sessions/697
Sessions/291
Sessions/2394
Sessions/772
Sessions/756
Sessions/1782
Sessions/1775
Sessions/277
Sessions/313
Sessions/275
Sessions/746
Sessions/734
Sessions/3298
Sessions/2446
Sessions/2177
Sessions/2455
Sessions/274
Sessions/340
Sessions/351
Sessions/2824
Sessions/2595
Sessions/2165
Sessions/2167
Sessions/3372
Sessions/2396
Sessions/2431
Sessions/3299
Sessions/2807
Sessions/2160
Sessions/377
Sessions/2777
Sessions/696
Sessions/344
Sessions/2774
Sessions/2802
Sessions/2556
Sessions/2122
Sessions/3357
Sessions/282
Sessions/2140
Sessions/755
Sessions/2816
Sessions/372
Sessions/688
Sessions/704
Sessions/279
Sessions/1800
Sessions/670
Sessions/1743
Sessions/283
Sessions/1747
Sessions/2097
Sessions/2739
Sessions/2731
Sessions/662
Sessions/2819
Sessions/2203
Sessions/2504
Sessions/2350
Sessions/335
Sessions/1806
Sessions/3362
Sessions/358
Sessions/779
Sessions/1809
Sessions/273
Sessions/2105
Sessions/2352
Sessions/1740
Sessions/2792
Sessions/2493
Sessions/2501
Sessions/2096
Sessions/363
Sessions/2437
Sessions/2491
Sessions/338
Sessions/1799
Sessions/1802
Sessions/2844
Sessions/2178
Sessions/2347
Sessions/677
Sessions/2351
Sessions/2141
Sessions/3339
Sessions/2476
Sessions/1763
Sessions/3335
Sessions/2374
Sessions/357
Sessions/2568
Sessions/1556
Sessions/747
Sessions/368
Sessions/2110
Sessions/1706
Sessions/3305
Sessions/2341
Sessions/328
Sessions/1737
Sessions/1704
Sessions/2185
Sessions/1697
Sessions/3307
Sessions/719
Sessions/2090
Sessions/2388
Sessions/3373
Sessions/760
Sessions/3325
Sessions/2848
Sessions/2565
Sessions/707
Sessions/3365
Sessions/1759
Sessions/1738
Sessions/2495
Sessions/321
Sessions/1539
Sessions/2833
Sessions/2490
Sessions/2399
Sessions/2765
Sessions/2425
Sessions/2361
Sessions/2380
Sessions/2598
Sessions/2790
Sessions/2448
Sessions/2554
Sessions/699
Sessions/1713
Sessions/738
Sessions/349
Sessions/1796
Sessions/376
Sessions/1517
Sessions/371
Sessions/1543
Sessions/682
Sessions/2404
Sessions/710
Sessions/2458
Sessions/2551
Sessions/1503
Sessions/3309
Sessions/693
Sessions/754
Sessions/2773
Sessions/667
Sessions/379
Sessions/385
Sessions/2408
Sessions/2363
Sessions/2820
Sessions/2805
Sessions/1754
Sessions/343
Sessions/2187
Sessions/2581
Sessions/1527
Sessions/1762
Sessions/2473
Sessions/770
Sessions/1753
Sessions/2814
Sessions/2164
Sessions/739
Sessions/304
Sessions/2429
Sessions/1812
Sessions/2109
Sessions/2421
Sessions/2196
Sessions/2107
Sessions/2527
Sessions/2427
Sessions/2353
Sessions/2522
Sessions/2533
Sessions/2152
Sessions/2200
Sessions/1516
Sessions/725
Sessions/2537
Sessions/322
Sessions/1749
Sessions/1744
Sessions/2752
Sessions/1712
Sessions/284
Sessions/2201
Sessions/2509
Sessions/752
Sessions/1808
Sessions/3295
Sessions/2115
Sessions/2390
Sessions/2583
Sessions/2371
Sessions/735
Sessions/2547
Sessions/356
Sessions/1547
Sessions/2176
Sessions/2103
Sessions/285
Sessions/2503
Sessions/384
Sessions/3328
Sessions/1734
Sessions/1554
Sessions/3358
Sessions/345
Sessions/2521
Sessions/2812
Sessions/778
Sessions/2344
Sessions/380
Sessions/2550
Sessions/365
Sessions/3346
Sessions/743
Sessions/1766
Sessions/2733
Sessions/2387
Sessions/2590
Sessions/1721
Sessions/2545
Sessions/2092
Sessions/2182
Sessions/1558
Sessions/262
Sessions/2839
Sessions/680
Sessions/1726
Sessions/2566
Sessions/2798
Sessions/3342
Sessions/2479
Sessions/2823
Sessions/2746
Sessions/2194
Sessions/339
Sessions/280
Sessions/2106
Sessions/2584
Sessions/1741
Sessions/2761
Sessions/2153
Sessions/2100
Sessions/3292
Sessions/264
Sessions/1526
Sessions/1504
Sessions/2463
Sessions/1472
Sessions/717
Sessions/1479
Sessions/288
Sessions/2847
Sessions/684
Sessions/2436
Sessions/2529
Sessions/731
Sessions/271
Sessions/2829
Sessions/1528
Sessions/1544
Sessions/2123
Sessions/1793
Sessions/1512
Sessions/1691
Sessions/654
Sessions/267
Sessions/1533
Sessions/2784
Sessions/3315
Sessions/2787
Sessions/3300
Sessions/1557
Sessions/1784
Sessions/2821
Sessions/2854
Sessions/3293
Sessions/2184
Sessions/692
Sessions/388
Sessions/2095
Sessions/2497
Sessions/312
Sessions/2345
Sessions/1523
Sessions/726
Sessions/289
Sessions/2457
Sessions/1771
Sessions/2535
Sessions/1480
Sessions/319
Sessions/2834
Sessions/777
Sessions/1794
Sessions/303
Sessions/2855
Sessions/1785
Sessions/2439
Sessions/2843
Sessions/2113
Sessions/2208
Sessions/2502
Sessions/2206