Hello All,
I am trying to do CNN Classification using Julia Flux but while doing so in one of the codes I am getting above mentioned error.
using Flux
using FileIO
using Plots
using Images
using MLDataUtils: splitobs, shuffleobs
using IterTools
function resize_and_grayify(directory, im_name, width::Int64, height::Int64)
resized_gray_img = Gray.(load(directory * "/" * im_name)) |> (x -> imresize(x, width, height))
try
save("preprocessed_" * directory * "/" * im_name, resized_gray_img)
catch e
if isa(e, SystemError)
mkdir("preprocessed_" * directory)
save("preprocessed_" * directory * "/" * im_name, resized_gray_img)
end
end
end
function process_images(directory, width::Int64, height::Int64)
files_list = readdir(directory)
map(x -> resize_and_grayify(directory, x, width, height), files_list)
end
n_resolution = 90
begin
process_images("path to image", n_resolution, n_resolution)
process_images("path to image", n_resolution, n_resolution);
end
begin
optimised_dir = readdir("path to image")
not_optimised_dir = readdir("path to image");
end
begin
optimised1 = load.("path to image/" .* optimised_dir)
not_optimised1 = load.("path to image/" .* not_optimised_dir);
end
optimised = optimised1
not_optimised = not_optimised1
data = vcat(optimised, not_optimised)
begin
labels = vcat([0 for _ in 1:length(optimised)], [1 for _ in 1:length(not_optimised)])
(x_train, y_train), (x_test, y_test) = splitobs(shuffleobs((data, labels)), at = 0.7)
end
function make_minibatch(X, Y, idxs)
X_batch = Array{Float32}(undef, size(X[1])..., 1, length(idxs))
for i in 1:length(idxs)
X_batch[:, :, :, i] = Float32.(X[idxs[i]])
end
Y_batch = onehotbatch(Y[idxs], 0:1)
return (X_batch, Y_batch)
end
begin
batchsize = 3
mb_idxs = partition(1:length(x_train), batchsize)
train_set = [make_minibatch(x_train, y_train, i) for i in mb_idxs]
test_set = make_minibatch(x_test, y_test, 1:length(x_test));
end
Can any one help me to solve the error?