I have a set of frames in which different animals are visible. I have annotated them using CVAT's polygon feature. Now, all I need to do is cropping the annotation part and extracting the features as a CSV file.
I can extract the features using VGG16 in MATLAB using a code like below:
net = vgg16;
I = imread('myImage.jpg');
featureMap = activations(net, I, 'pool5');
disp(featureMap);
As I want to use my data in Weka, and I want to get rid of image files and I want to train my algorithm using the features. The algorithms that I want to use are Decision Tree, SVM and RCNN.
How can I crop the annotated part in CVAT? and How can I get my features as a CSV file?
CodePudding user response:
First, I uploaded the COCO results of CVAT with the output images to Roboflow and cropped the images based on the defined rectangle box in COCO (JSON) file.
After that, as I had three different classes, I created three different folders and named them like my classes. Then, I copied cropped images of each class to the relevant folder.
Finally, using MATLAB, I ran the following code to extract the features using vgg16:
imds = imageDatastore('E:/...', ...
'IncludeSubfolders',true,'LabelSource','foldernames');
%%
[imdsTrain, imdsValidation] = splitEachLabel(imds,0.7,'randomized');
%%
net = vgg16;
%%
layer = 'fc8';
%%
featuresTrain = activations(net, imdsTrain, layer, 'OutputAs','channels');
featuresTest = activations(net, imdsValidation, layer, 'OutputAs','channels');
Having the train set and test set ready I created two different .csv
files, and copied their content to those two files and for classification, I used WEKA.