I currently have a program that uses template matching to get x,y coordinates of a cursor from a screenshot, which then stores that in the filename in the format screenshotNo-xxx-yyy. The function below converts the path into the correct keypoints tensor, which works as it should:
def img2kpts(f):
name = os.path.basename(f)
split = str(name).split("-")
kpts = []
kpts.append([int(split[1]), int(split[2][:-4])])
return tensor(kpts)
Example:
img2kpts(lbls[799])
would return
tensor([[529, 208]]).
However, after putting this into a datablock specified below, when checking the summary with
dblock.summary('')
I get the error “IndexError: list index out of range” from the line
kpts.append([int(split[1]), int(split[2][:-4])])
where split[1] is highlighted
Other important code below:
dblock = DataBlock(blocks=(ImageBlock, PointBlock),
get_items=get_image_files,
splitter=RandomSplitter(),
get_y=img2kpts)
path = Path("C:/Users/joshu/Desktop/Data/osu-ai")
imgs = get_image_files(path)
lbls = get_files(path, extensions='.png')
print(f"Total Images:{len(imgs)}")
Total Images:2554
Please let me know if you require anything else.