summaryrefslogtreecommitdiff
path: root/test/model.py
blob: f7fc57e96256340cf3f39f091907aa39dd024406 (plain)
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
import os

from config import config
from models.model import Model
from utils.dataset import ClipConditions

conf = config
os.chdir('..')


def test_default_signature():
    model = Model(conf['system'], conf['model'], conf['hyperparameter'])
    casiab = model._parse_dataset_config(conf['dataset'])
    model._parse_dataloader_config(casiab, conf['dataloader'])
    assert model._log_name == os.path.join(
        'runs', 'logs', 'RGB-GaitPart_80000_64_128_128_64_1_2_4_True_True_32_5_'
                        '3_3_3_3_3_2_1_1_1_1_1_0_2_3_4_16_256_0.2_0.0001_0.9_'
                        '0.999_0.001_500_0.9_CASIA-B_74_30_15_3_64_32_8_16')
    assert model._checkpoint_sig == ('RGB-GaitPart_0_80000_64_128_128_64_1_2_4_'
                                     'True_True_32_5_3_3_3_3_3_2_1_1_1_1_1_0_2_'
                                     '3_4_16_256_0.2_0.0001_0.9_0.999_0.001_'
                                     '500_0.9_CASIA-B_74_30_15_3_64_32_8_16')


def test_default_signature_with_selector():
    model = Model(conf['system'], conf['model'], conf['hyperparameter'])
    casiab = model._parse_dataset_config(dict(
        **conf['dataset'],
        **{'selector': {'conditions': ClipConditions({r'nm-0\d', r'bg-0\d'})}}
    ))
    model._parse_dataloader_config(casiab, conf['dataloader'])
    assert model._log_name == os.path.join(
        'runs', 'logs', 'RGB-GaitPart_80000_64_128_128_64_1_2_4_True_True_32_5_'
                        '3_3_3_3_3_2_1_1_1_1_1_0_2_3_4_16_256_0.2_0.0001_0.9_'
                        '0.999_0.001_500_0.9_CASIA-B_74_30_15_3_64_32_bg-0\\d_'
                        'nm-0\\d_8_16')
    assert model._checkpoint_sig == ('RGB-GaitPart_0_80000_64_128_128_64_1_2_4_'
                                     'True_True_32_5_3_3_3_3_3_2_1_1_1_1_1_0_2_'
                                     '3_4_16_256_0.2_0.0001_0.9_0.999_0.001_'
                                     '500_0.9_CASIA-B_74_30_15_3_64_32_bg-0\\d_'
                                     'nm-0\\d_8_16')