-
Notifications
You must be signed in to change notification settings - Fork 10
/
dataset-stats
44 lines (31 loc) · 1.22 KB
/
dataset-stats
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
#!/usr/bin/env python
import argparse
from dsf.data import lemnatec
from datetime import datetime
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)
# Number of snapshots
snapshot_count = len(meta["environment"])
# Number of images
image_count = len(meta["images"])
# Find the experiment start and end dates
dates = []
for snapshot in meta["environment"]:
timestamp = meta["environment"][snapshot]["timestamp"]
dates.append(datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%fZ"))
dates.sort()
start_date = dates[0].date().strftime("%Y-%m-%d")
end_date = dates[-1].date().strftime("%Y-%m-%d")
print("start_date end_date snapshots images")
print(" ".join(map(str, [start_date, end_date, snapshot_count, image_count])))
if __name__ == "__main__":
main()