function [trainImgs, testImgs, trainLabels, testLabels]=splitData_AnimalFace(imgPath, categoryNames, numClass, sy)
    
  
    trainImgs = cell(0);
    testImgs = cell(0);
    trainLabels = [];
    testLabels=[];
    % load images from src domain
    for iClass = 1:numClass  
               
        if exist(fullfile(imgPath, categoryNames{iClass}), 'dir') == 0
	       error( ['Cannot find target directory: ' fullfile(imgPath, categoryNames{iClass})]);
        end 
        
        imgList = dir(fullfile(imgPath, categoryNames{iClass},'*.jpg'));
        disp( ['category ',  num2str(iClass), ': ' categoryNames{iClass}, ' has ' num2str(length(imgList)) ' images']);
        
        num_train=round(length(imgList)/2)
        idx= randperm(length(imgList));
        
        for iImg= 1:num_train
            img = imread(fullfile(imgPath, categoryNames{iClass},imgList(idx(iImg)).name));
            img = imresize(img,[sy sy]);
            trainImgs{end+1}=img;
            trainLabels = [trainLabels; iClass];
        end
        
        
        for iImg = num_train +1 :length(idx)
            img = imread(fullfile(imgPath,categoryNames{iClass},imgList(idx(iImg)).name));
            img = imresize(img,[sy sy]);
            testImgs{end+1}=img;
            testLabels = [testLabels; iClass];
        end
       
        
    end
end
