You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
844 B
Python
35 lines
844 B
Python
# this file computes statistics of the datasets
|
|
|
|
import os
|
|
import json
|
|
|
|
|
|
stat = {}
|
|
def stat_scene(scene):
|
|
|
|
label_folder = os.path.join("./", scene, "label")
|
|
label_files = os.listdir(label_folder)
|
|
|
|
for file in label_files:
|
|
if os.path.splitext(file)[1] != '.json':
|
|
continue
|
|
|
|
with open(os.path.join(label_folder, file)) as f:
|
|
labels = json.load(f)
|
|
|
|
for l in labels:
|
|
#color = get_color(l["obj_id"])
|
|
obj_type = l["obj_type"]
|
|
if stat.get(obj_type):
|
|
stat[obj_type] = stat[obj_type] + 1
|
|
else:
|
|
stat[obj_type] = 1
|
|
|
|
return stat
|
|
|
|
if __name__=="__main__":
|
|
for s in os.listdir("./"):
|
|
print("stat {}".format(s))
|
|
stat = stat_scene(s)
|
|
for x in stat:
|
|
print(x, stat[x]) |