使用Juno / LT运行Julia Code,Error,`getindex`没有匹配getindex的方法(:: DataFrame,:: ASCIIString

时间:2015-10-27 05:58:06

标签: julia

以下是我正在使用的代码的第一部分。这个代码的目的是,当给出.bmp格式的图像文件时,正确识别图像中显示的字母。

#Install required packages
Pkg.add("Images")
Pkg.add("DataFrames")
using Images
using DataFrames


#typeData could be either "train" or "test.
#labelsInfo should contain the IDs of each image to be read
#The images in the trainResized and testResized data files
#are 20x20 pixels, so imageSize is set to 400.
#path should be set to the location of the data files.

function read_data(typeData, labelsInfo, imageSize, path)

#Intialize x matrix
 x = zeros(size(labelsInfo, 1), imageSize)

for (index, idImage) in enumerate(labelsInfoTrain["ID"])
  #Read image file
  nameFile = "$(path)/$(typeData)Resized/$(idImage).Bmp"
  img = imread(nameFile)
  #Convert img to float values
  temp = float32sc(img)
  #Convert color images to gray images
  #by taking the average of the color scales.
  if ndims(temp) == 3
   temp = mean(temp.data, 1)
  end
  #Transform image matrix to a vector and store
  #it in data matrix
  x[index, :] = reshape(temp, 1, imageSize)
 end
 return x
end
imageSize = 400 # 20 x 20 pixels

#Set location of data files , folders
#Probably will need to set this path to which folder your files are in
path = "C:\\Users\\Aaron\\Downloads\\Math512Project"

#Read information about test data ( IDs )
labelsInfoTest = readtable("$(path)/sampleSubmissionJulia.csv")

#Read test matrixnformation about training data , IDs.
labelsInfoTrain = readtable("$(path)/trainLabels.csv")

#Read training matrix

xTrain = read_data("train", labelsInfoTrain, imageSize, path)

我遇到的错误是当我的程序到达上面最后一行代码时:

xTrain = read_data("train", labelsInfoTrain, imageSize, path)

我收到一条错误消息:getindex没有匹配getindex的方法(:: dataFeff,:: :: ASCIIString ::::::::::::::::::::::::::

指的是代码行:

for (index, idImage) in enumerate(labelsInfoTrain["ID"])

在线研究让我深入了解了使用DataFrames包和Image包时问题与冲突有关。我被建议改变" ID"在我的代码[:ID],但这不解决问题,而是导致另一个错误。我想知道是否有人新的如何解决这个问题或我的代码到底是什么问题。在Julia命令行0.4.0中运行代码时出现相同的错误。期待收到你的回复。

0 个答案:

没有答案