File size: 1,075 Bytes
63775f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from findfile import find_files, find_dir

filter_key_words = [
    ".py",
    ".md",
    "readme",
    "log",
    "result",
    "zip",
    ".state_dict",
    ".model",
    ".png",
    "acc_",
    "f1_",
    ".backup",
    ".bak",
]


def detect_infer_dataset(dataset_path, task="apc"):
    dataset_file = []
    if isinstance(dataset_path, str) and os.path.isfile(dataset_path):
        dataset_file.append(dataset_path)
        return dataset_file

    for d in dataset_path:
        if not os.path.exists(d):
            search_path = find_dir(
                os.getcwd(),
                [d, task, "dataset"],
                exclude_key=filter_key_words,
                disable_alert=False,
            )
            dataset_file += find_files(
                search_path,
                [".inference", d],
                exclude_key=["train."] + filter_key_words,
            )
        else:
            dataset_file += find_files(
                d, [".inference", task], exclude_key=["train."] + filter_key_words
            )

    return dataset_file