warn("$file does not exist")

is trying to reference a variable named file, which (as the error message 
indicates) is undefined. Presumably you want this to be

    warn("$nameFile does not exist")

--Tim

On Tuesday, April 05, 2016 11:16:06 AM [email protected] wrote:
> Hi Friends,
> 
> 
> I am trying to test the implementation of character recognition using Julia
> in my Windows 10 machine using the tutorial from
> https://www.kaggle.com/c/street-view-getting-started-with-julia/data. I am
> trying to train my system using the sample images and the code works fine
> in mac and in windows machine I am facing the trouble.
> 
> 
> Below is the code which I am using to implement it.
> 
> Pkg.add("Images")
> 
> Pkg.add("DataFrames")
> 
> 
> using Images
> 
> using DataFrames
> 
> using Images.ColorTypes
> 
> using FixedPointNumbers
> 
> using Iterators
> 
> 
> function read_data(typeData, labelsInfo, imageSize, path)
> 
> x = zeros(size(labelsInfo, 1), imageSize)
> 
> if !ispath(path)
> 
> error("$path is not valid")
> 
> end
> 
> for (index, idImage) in enumerate(labelsInfo[:ID])
> 
> nameFile = "C:\\Users\\user\\Desktop\\test
> \\OCR_test\\$(typeData)Resized\\$(typeData)Resized\\$(idImage).bmp"
> 
> if isfile(nameFile)
> 
> img = load(nameFile)
> 
> 
> temp = convert(Image{Gray}, img)
> 
> 
> x[index, :] = reshape(temp, 1, imageSize)
> 
> 
> else
> 
> warn("$file does not exist")
> 
> end
> 
> end
> 
> return x
> 
> end
> 
> 
> imageSize = 400
> 
> 
> 
> path = "C:\\Users\\user\\Desktop\\test\\OCR_test"
> 
> 
> println(path)
> 
> labelsInfoTrain = readtable("$(path)\\trainLabels.csv")
> 
> 
> xTrain = read_data("train", labelsInfoTrain, imageSize, path)
> 
> 
> 
> yTrain = map(x -> x[1], labelsInfoTrain[:Class])
> 
> 
> yTrain = int(yTrain)
> 
> 
> 
> labelsInfoTest = readtable("$(path)\\sampleSubmission.csv")
> 
> 
> xTest = read_data("test", labelsInfoTest, imageSize, path)
> 
> 
> 
> Pkg.add("DecisionTree")
> 
> using DecisionTree
> 
> 
> model = build_forest(yTrain, xTrain, 20, 50, 1.0)
> 
> 
> predTest = apply_forest(model, xTest)
> 
> 
> labelsInfoTest[:Class] = char(predTest)
> 
> writetable("$(path)\\juliaSubmission.csv", labelsInfoTest, header=true,
> separator=',')
> 
> 
> Below is the error I am getting while implementing the code
> 
> 
> julia> include("C:\\Users\\user\\Desktop\\test\\OCR_test\\Forest.jl")
> 
> INFO: Nothing to be done
> 
> INFO: Nothing to be done
> 
> C:\Users\user\Desktop\test\OCR_test
> 
> ERROR: LoadError: UndefVarError: file not defined
> 
>  in read_data at C:\Users\user\Desktop\test\OCR_test\Forest.jl:25
> 
>  in include at boot.jl:261
> 
>  in include_from_node1 at loading.jl:304
> 
> while loading C:\Users\user\Desktop\test\OCR_test\Forest.jl, in expression
> starting on line 43
> 
> 
> I am new to Julia and I really appreciate any help you could provide on this
> 
> 
> Thanks & Regards

Reply via email to