Help needed with Facial recognition coding

I am looking for some help on how to code a facial recognition program and make it highly accurate, I have been given a code from a lecture and have been asked to make it more accurate. I have never done any type of coding in python before and have no idea of where to begin. I understand that to make the program more accurate I will need to add hidden nodes within the program but not sure how ??

Below is the code I have been given and I also have 50 images for the program to run.
Any tips or help would be very much appreciated.

function main() % ver /02/19
global dname val_ratio nofpc nofhn nofpix

% Set the path to a folder (eg A1) which contains the face images on your PC
dname=‘BFR_task’;

% Settings for experiments:
nofpc=100; % set a number of principal components
nofhn=20; % set a number of hidden neurons for ANN

% Advanced settings:
nofpix=32; % size of face images
val_ratio=0.3; % recommended part of the training set used for validation of ANN

% Steps 1 to 4:

% Step 1: Read image set
[X,T]=read_image_set();

% Step 2: Split imsge data set into training and test subsets
[X1,T1,X2,T2]=split_image_set(X,T);

% Step 3: Apply PCA to the training and test subsets
[PS1,PS2]=apply_pca(X1,X2);

% Step 4: Train ANN
[~,vacc]=train_net(PS1,PS2,T1,T2);
fprintf(‘Accuracy of recognition on validation subset %5.3f\n’,vacc)

return

% Scripts for Steps 1 to 4

function [X,T]=read_image_set() % Step 1
%
% Notation:
% Np=30 is the number of persons to be recognised by the given images
% Each person is taken 50 times, k=50.
% The images are reshaped to be 32 by 32 pixels.
% The number of images N=Npk=3050=1500.
% Inputs:
% There are N jpg images representing the Np persons.
% Function:
% Each image is vectorised to be a vector including
% L=3232=1024 elements.
% Ouputs:
% X is the (L by N) matrix of vectorised images of Np persons.
% T is the N-element target vector including the person indexes 1 to Np
% Settings:
% dname is the folder name including all the N images.
% nofpix=30 is the size of images in pixels, It can be reasonably
% changed for improving the recognition accuracy.
%
global dname nofpix
nofvect=nofpix
nofpix;
path(dname,path);
Fn=dir(dname);
n=size(Fn,1);
N=n-2;
X=single(zeros(nofvect,N));
TA=single(zeros(1,N));
for i=3:n
fname=Fn(i).name;
Im=imread(fname,‘jpg’);
%figure(1)
%imshow(Im) % uncomment if you want to see the image
Im1=imresize(Im,[nofpix nofpix]);
%figure(2)
%imshow(Im1)
V=single(Im1(:));
i1=i-2;
X(:,i1)=V;
TA(i1)=str2double(fname(6:7));
end
T=call_order_labels(TA);
return

function T=call_order_labels(TA)
U=unique(TA);
n=length(U);
T=zeros(size(TA));
for i=1:n
I=TA==U(i);
T(I)=i;
end
return

function [X1,T1,X2,T2]=split_image_set(X,T) % Step 2
%
% Inputs:
% X, T are the input data and labels calculated by the function read_image_set().
% Function:
% The data X,T are split into training and validation subsets X1,T1 and X2,T2.
% Images in the subsets are randomly assigned accordingly
% to the given val_ratio.
% Outputs:
% X1 is the (L by n1) matrix of training set.
% T1 is the n1-element target vector of images in the validation set.
% X2 is the (L by n2) matrix of validation set.
% T2 is the n2-element target vector of images in the validation set.
% Settings:
% val_ratio=0.3. This ratio can be reasonably changed to achieve
% the maximal accuracy of test (unseen) images .
%
global val_ratio
nofim=size(X,2); % nof images
I1=true(1,nofim);
nofvalimages=round(nofim*val_ratio);
A2=randsample(nofim,nofvalimages); % validation images
I1(A2)=false; % flags for train images
I2=~I1; % flags for validation images
X1=X(:,I1);
T1=T(I1);
X2=X(:,I2);
T2=T(I2);
return

function [PS1,PS2,C,M]=apply_pca(X1,X2) % Step 3
%
% Notation:
% nofpc is the number of principal components extracted from the
% images
% Inputs:
% X1,X2 are the training and validation images prepared
% by the function split_image_set().
% Function:
% PCA is applied to the set X1 to find the components P1 and matrix of
% coefficients C.
% Outputs:
% PS1 is the (nofpc by n1) matrix of components for training set.
% PS2 is the (nofpc by n2) matrix of components for training set.
% Settings:
% nofpc=100 by default can be reasonably changed to improve
% the recognition accuracy
%
global nofpc
% train set:
[P1,C]=processpca(X1);
[PM1,M]=mapstd(P1);
% test set:
P2=processpca(‘apply’,X2,C);
PM2=mapstd(‘apply’,P2,M);
% get components:
PS1=PM1(1:nofpc,:);
PS2=PM2(1:nofpc,:);
return

function [Net,vacc]=train_net(X1,X2,T1,T2) % Step 4
%
% Inputs:
% X1,X2 are the training and validation images prepared by the function
% split_image_set().
% Function:
% Train an artificial neural network (Net) with the given number (nofhn)
% of hidden neurons and training method (trainscq).
% Validate the accuracy of the trained network (Net) on the validation data X2
% Outputs:
% Net is the trained feedforward ANN
% Settings:
% nofhn=20 by default can be reasonably changed to improve
% the recognition accuracy
%
global nofhn
TV1=full(ind2vec(T1)); % read about the function ind2vec()
Net=feedforwardnet(nofhn,‘trainscg’);
Net=train(Net,X1,TV1); % train ANN
YV2=Net(X2);
Y2=vec2ind(YV2);
vacc=mean(T2==Y2); % accuracy rate [0,1]
return