i have the following dataset as files,
image voice
0 -64VH3Apae0.npy -64VH3Apae0.npy
1 -6zgNLiO0hw.npy -6zgNLiO0hw.npy
2 -8LOU7c__hc.npy -8LOU7c__hc.npy
3 -9vlXXK491c.npy -9vlXXK491c.npy
4 -f2d0VPU3Zg.npy -f2d0VPU3Zg.npy
... ... ...
1230 _S_OkdQlox8.npy _S_OkdQlox8.npy
1231 _ua2HGzbvn8.npy _ua2HGzbvn8.npy
1232 _XexneTqik4.npy _XexneTqik4.npy
1233 _xg8VLVfYSI.npy _xg8VLVfYSI.npy
1234 _YAclFXGGpM.npy _YAclFXGGpM.npy
i want to load each file from image tag and append to array called im_features, i tried to do the following,
def createImageFeatures(table):
file_im_feature = np.load(image_features + str(table.image), allow_pickle=True)
im_features = np.append(im_features, file_im_feature[0], axis=1)
dataset.apply(createImageFeatures, axis=1)
but got
UnboundLocalError: local variable 'im_features' referenced before
assignment
example:
im_features1 = np.load(image_features + '-64VH3Apae0.npy', allow_pickle=True)
im_features2 = np.load(image_features + '4QgpaBUYeI4.npy', allow_pickle=True)
print(im_features1[0])
[[0.28235294]
[0.28627451]
[0.32156863]
...
[0.17647059]
[0.17647059]
[0.18431373]]
print(im_features2[0])
[[1. ]
[1. ]
[1. ]
...
[0.16862745]
[0.15294118]
[0.14117647]]
np.append(im_features1[0], im_features2[0], axis=1)
im_features = np.append(im_features1[0], im_features2[0], axis=1)
print(im_features)
[[0.28235294 1. ]
[0.28627451 1. ]
[0.32156863 1. ]
...
[0.17647059 0.16862745]
[0.17647059 0.15294118]
[0.18431373 0.14117647]]
how to achieve such thing.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…