We want the png files to be accessed as 15.png,45.png,75.png and so on. This is the code and the output we are getting
import os
keypts_labels=[]
class_list=os.listdir('dataset')
for name in class_list:
for image in os.listdir(f"dataset/{name}"):
for item in os.listdir(f"dataset/{name}/{image}"):
print(os.path.abspath(f"dataset/{name}/{image}/{item}"))
You don't need to handle all this iterating logic, when there are easy ways to do it. See the approach below
This piece of function will actually list what you need. This assumes, all png files has the name a valid number, and you are searching only for png files.
I hope the logic is understood from the comments itself.