2019-11-15 07:15:07 +01:00
|
|
|
##################################################
|
|
|
|
# Copyright (c) Xuanyi Dong [GitHub D-X-Y], 2019 #
|
|
|
|
##################################################
|
2020-01-16 13:37:14 +01:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
2019-09-28 10:24:47 +02:00
|
|
|
def test_imagenet_data(imagenet):
|
2021-04-22 13:12:21 +02:00
|
|
|
total_length = len(imagenet)
|
|
|
|
assert (
|
|
|
|
total_length == 1281166 or total_length == 50000
|
|
|
|
), "The length of ImageNet is wrong : {}".format(total_length)
|
|
|
|
map_id = {}
|
|
|
|
for index in range(total_length):
|
|
|
|
path, target = imagenet.imgs[index]
|
|
|
|
folder, image_name = os.path.split(path)
|
|
|
|
_, folder = os.path.split(folder)
|
|
|
|
if folder not in map_id:
|
|
|
|
map_id[folder] = target
|
|
|
|
else:
|
|
|
|
assert map_id[folder] == target, "Class : {} is not {}".format(
|
|
|
|
folder, target
|
|
|
|
)
|
|
|
|
assert image_name.find(folder) == 0, "{} is wrong.".format(path)
|
|
|
|
print("Check ImageNet Dataset OK")
|