1
我正在计算从目录读取的图像的功能,我想将图像路径和相应的功能写入文件中,并用空格分隔。输出期望以这种方式如何在文件中编写一个字符串和一个numpy数组?
/path/to/img1.jpg 1 0 0 1 3.5 0.2 0
/path/to/img2.jpg 0 0 0.5 2.1 0 0.7
...
以下是我的代码
features.open('file.txt', 'w')
for fname in fnmatch.filter(fileList, '*.jpg'):
image = '/path/to/image'
# All the operations are here
myarray = [......] # array of dimensions 512x512
myarray.reshape(1, 512*512) # Reshape to make it a row vector
features.write(image + ' '.join(str(myarray)))
features.write('\n')
features.close()
一部分,但输出来作为
/path/to/img1.jpg[[0 0 1.0 2 3]]
/path/to/img2.jpg[[1.2 0 1.0 2 0.3]]
您能否定义“不正确?”一点也不?输出如何? – tfv
编辑帖子。 –