-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdataset-qc
60 lines (49 loc) · 1.41 KB
/
dataset-qc
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
#!/usr/bin/env python
import os
import json
import argparse
from dsf.data import lemnatec
def options():
parser = argparse.ArgumentParser(description='Output dataset statistics.',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("-d", "--dataset", help="Dataset directory.", required=True)
args = parser.parse_args()
return args
def main():
# Read user options
args = options()
# Load the dataset metadata
meta = lemnatec.load_dataset(dataset_dir=args.dataset)
# Good/bad images
stats = {
"VIS-SV": {
"total": 0,
"incomplete": 0
},
"VIS-TV": {
"total": 0,
"incomplete": 0
},
"NIR-SV": {
"total": 0,
"incomplete": 0
},
"NIR-TV": {
"total": 0,
"incomplete": 0
},
"FLUO-TV": {
"total": 0,
"incomplete": 0
}
}
for img in meta["images"]:
imgtype = meta["images"][img].get("imgtype")
imgtype = imgtype.upper()
camera = meta["images"][img].get("camera")
stats[f"{imgtype}-{camera}"]["total"] += 1
if not os.path.exists(os.path.join(args.dataset, img)):
stats[f"{imgtype}-{camera}"]["incomplete"] += 1
print(json.dumps(stats, indent=4))
if __name__ == "__main__":
main()