[Python] finding the complete path of an image

Discussão em 'Python' iniciado por Stack, Maio 31, 2025.

  1. Stack

    Stack Membro Participativo

    C:\Users\siva\Downloads\ASL-Finger-Spelling-Recognition-master\asl_dataset\1


    like the above path there will be several images 0-9 and a-z hence there are 36 classes. In the above path the last one indicates the number 1. In the below program i have to find that one by traversing it but it ended up with


    ASL-Finger-Spelling-Recognition-master producing a key error at y_train.append(classes[fullpath[n + 1:t]]) because classes[ASL-Finger-Spelling-Recognition-master] does not exists.
    ​

    def load_data_set():
    for path in paths:
    for root, directories, filenames in os.walk(path):
    for filename in filenames:
    if filename.endswith(".jpeg"):
    fullpath = os.path.join(root, filename)
    img = load_img(fullpath)
    img = img_to_array(img)
    print fullpath
    x_train.append(img)
    t = fullpath.rindex("/")
    fullpath = fullpath[0:t]
    n = fullpath.rindex("/")
    #print fullpath[n + 1:t]
    y_train.append(classes[fullpath[n + 1:t]])

    Continue reading...

Compartilhe esta Página