Scene-Graph-Benchmark.pytorch
Scene-Graph-Benchmark.pytorch copied to clipboard
AssertionError
❓ Questions and Help
File "/home/xxd/1 scene graph/Scene-Graph-Benchmark.pytorch-master/maskrcnn_benchmark/data/datasets/visual_genome.py", line 291, in load_image_filenames assert len(fns) == 108073 AssertionError
Does anyone encounter this problem?thk
It could be caused by the wrong DATAPATH, i.e., in line 288: "if os.path.exists(filename)" cannot access the images
I had the same problem because I did not download the dataset images as I was trying on custom images. So commented out assertions and few other lines as below:
def load_image_filenames(img_dir, image_file):
"""
Loads the image filenames from visual genome from the JSON file that contains them.
This matches the preprocessing in scene-graph-TF-release/data_tools/vg_to_imdb.py.
Parameters:
image_file: JSON file. Elements contain the param "image_id".
img_dir: directory where the VisualGenome images are located
Return:
List of filenames corresponding to the good images
"""
with open(image_file, 'r') as f:
im_data = json.load(f)
corrupted_ims = ['1592.jpg', '1722.jpg', '4616.jpg', '4617.jpg']
fns = []
img_info = []
for i, img in enumerate(im_data):
basename = '{}.jpg'.format(img['image_id'])
if basename in corrupted_ims:
continue
filename = os.path.join(img_dir, basename)
#if os.path.exists(filename):#####################
fns.append(filename)
img_info.append(img)
print(len(fns))
print(len(img_info))
#assert len(fns) == 108073#####################
#assert len(img_info) == 108073#####################
return fns, img_info
Worked fine.