Data Preparation for TGS Salt Identification

I am writing a Unet in Flux.jl for TGS Salt identification challenge .
The data is organised as follows:-
data/train/images - contains (101x101x3) training images
data/train/masks - contains (101x101x1) training masks (labels)
data/train/train.csv - contains name of the training images and their corresponding masks
My Code is:-

Blockquote

This function creates array of shapes X - (101x101x3xn) , Y - (101x101x1xn)

i.e in the format of (width, height, channel, batch_size) (w, h, c, n)

function load_data(train_df, base_dir, n,rsize = (101,101))
img_dir = “images/”
mask_dir = “masks/”
x= zeros(UInt8,rsize…,3, n) #
y = zeros(UInt8, rsize…, 1,n)
count = 1
for i in train_df[!, “id”]
try
if isfile(string(joinpath(base_dir, img_dir, i), “.png”)) && isfile(string(joinpath(base_dir, mask_dir, i), “.png”))
img = load(string(joinpath(base_dir, img_dir, i), “.png”))
img = convert(Image{Gray}, img)
mask = load(string(joinpath(base_dir, mask_dir, i), “.png”))
img = channelview(img)
mask = channelview(mask)
x′ = @view x[:,:,:,count]
x′ .= img
y′ = @view y[:,:,:,count]
y′ .= mask
append(x,x′)
append(y, y′)
count += 1
end
catch ArgumentError
end
end
x, y
end

The code for the Unet is:-

function Unet()
c1 = convBlock(3, 6, (3,3))
c1_next = convBlock(6,6, (3,3))
p1 = MaxPool((2, 2))
c2 = convBlock(6,12, (3,3))
c2_next = convBlock(12,12, (3,3))
p2 = MaxPool((2,2))
c3 = convBlock(12,25, (3,3))
c3_next = convBlock(25,25, (3,3))
p3 = MaxPool((2,2))
c4 = convBlock(25,50, (3,3))
c4_next = convBlock(50,50, (3,3))
p4 = MaxPool((2,2))
ct1 = convTransBlock(101,50, (3,3))
ct1_next = convBlock(50,50, (3,3))
ct2 = convTransBlock(50,25, (3,3))
ct2_next = convBlock(25,25, (3,3))
ct3 = convTransBlock(25,12, (3,3))
ct3_next = convBlock(12,12, (3,3))
ct4 = convTransBlock(12,6, (3,3))
ct4_next = convBlock(6,6, (3,3))
return Chain(
# _______________ Conv 1
c1,
Dropout(0.1),
c1_next,
p1,
# ________________ Conv 2
c2,
Dropout(0.1),
c2_next,
p2,
# _______________ Conv 3
c3,
Dropout(0.2),
c3_next,
p3,
# _______________ Conv 4
c4,
Dropout(0.2),
c4_next,
p4,
# _______________ Conv 5
convBlock(50,101),
convBlock(101,101),
#_______________ Expand 1
ct1,
cat(ct1, c4_next, dims=4),
ct1_next,
Dropout(0.2),
ct1_next,
#_______________Expand 2
ct2,
cat(ct2, c3_next, dims=4),
ct2_next,
Dropout(0.2),
ct2_next,
#_______________Expand 3
ct3,
cat(ct3, c2_next, dims=4),
ct3_next,
Dropout(0.2),
ct3_next,
#__Expand 4
ct4,
cat(ct4, c1_next, dims=4),
ct4_next,
Dropout(0.2),
ct4_next,
#
Output
convBlock(6, 1, (1,1)))
end

The data preparation and the training code is:-

base_dir = “data/train/”
x_train, y_train = load_data(train_df, base_dir, 4000)
train_data = Flux.Data.DataLoader(x_train, y_train, batchsize=10)
m = Unet()
p = params(m)
loss(x, y) = crossentropy(m(x), y)
opt = ADAM(0.001, (0.9, 0.8))
epochs = 1
@epochs epochs Flux.train!(loss, p, train_data, opt, cb = () → println(“Training”))

On running the code I get the following error:-
MethodError: objects of type Array{Chain,4} are not callable
Use square brackets for indexing an Array.

“Please help me! I am not able to move ahead. Please recommend all the edits and changes that should be done in the code.”