关键词 > ECS4422/5323

ECS 4422/5323 Computer Vision, Fall 2021 Assignment 3 - Machine Learning

发布时间:2022-03-06

Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

ECS 4422/5323 Computer Vision, Fall 2021

Assignment 3 - Machine Learning

All programming questions are to be completed in MATLAB. This assignment is to be done individually. Do not use code from the web (other than the code instructed to use). If in doubt about external code usage, please reach out to us. We will be checking for copying using MOSSand reserve the right to give ofenders (both copier and source) a zero on this assignment and pursue academic sanctions.

You are given:

● a directory of cropped grayscale face images, called broppdc tr_ininf im_fds e_bds,

● a directory of images without faces, called im_fds note_bds,

● a skeleton script called fdndr_td broppdc note_bds.m,

● a skeleton script called fdt ed_turds.m,

● a skeleton script called tr_in sⅤm.m, and

● a helper script called rdport _bbur_by.m (do not edit this file).

1    K-nearest neighbours (Total 10)

Implement a K-nearest neighbour classifier. Classify each input according to the most frequent class among the K- nearest neighbours, i.e., face or not a face. Find the optimal value of K using cross validation. Draw a graph that shows the accuracy as K increases from 1 to 20. For full marks, your classifier should be fully vectorized, i.e., no loops are used.

For your positive dataset (i.e., faces), use the directory of cropped grayscale face images, called

broppdc tr_ininf im_fds e_bds.  For your negative set (i.e., non-faces), use the images in im_fds note_bds, generate a set of cropped, grayscale, non-face images using fdndr_td broppdc note_bds.m. The images should be 36 × 36, like the face images. Reserve a random sampling of 20% of the images in each of the positive and negative datasets for evaluation.

Separately, you will consider to diferent input representations:  (i) the raw greyscale images and (ii) the input images represented as HOG features. A useful resource is the VLFeat tutorial on HOG: gttp://vvv.Ⅴled_t.orf/ oⅤdrⅤidv/gof.gtml.

2    Face detection (30 points)

In this part of the assignment, you will be implementing various parts of a sliding window object detector [1]. In par- ticular, you are tasked with implementing a multi-scale face detector. You need to train an SVM to categorize 36 × 36 pixel images as “face” or “not face”, using HOG features. Use the VLFeat library (gttp://vvv.Ⅴled_t.orf/) for

both HOG and the SVM.

1.  [5 points]  Using the images in im_fds note_bds, generate a set of cropped, grayscale, non-face images. Use fdndr_td broppdc note_bds.m as your starting point. The images should be 36 × 36, like the face images.

2.  [5 points]  Split your training images into two sets: a training set, and a validation set. A good rule of thumb is to use 80% of your data for training, and 20% for validation.

3.  [5 points]  Generate HOG features for all of your training and validation images. Use fdt ed_turds.m as your starting point.  You are free to experiment with the details of your HOG descriptor.  A useful resource is the VLFeat tutorial on HOG: gttp://vvv.Ⅴled_t.orf/oⅤdrⅤidv/gof.gtml

4.  [5 points]   Train an SVM on the features from your training set.  Use tr_in sⅤm.m as your starting point. The parameter “l_mac_” will help you control overfitting. A useful resource is the VLFeat tutorial on SVMs: gttp://vvv.Ⅴled_t.orf/m_tl_a/Ⅴl  sⅤmtr_in.gtml.  Note:  If you test your SVM on the training set features, you should get near perfect accuracy.

5.  [5 points]  Test your SVM on the validation set features. From the SVM’s performance at this step, try to refine the parameters you chose in the earlier steps (e.g., the cell size for HOG, and l_mac_ for the SVM). Save your final SVM (weights and bias) in a m_t file called my sⅤm.m_t, and include it in your submission.

6.  [5 points]  Write a script called rdbof summ_ry.m, which prints out a brief summary of your approach (using eprinte). Be sure to include your best accuracy on the validation set, and what you did to improve performance.

3    Multi-scale face detection (35 points)

In this part, you need to create a multi-scale sliding window face detector.

In addition to the files from Part 1, you are given:

● an image called bl_ss.jpf,

● a skeleton script called cdtdbt.m,

● a directory of grayscale test images, called tdst im_fds,

● bounding box annotations for the test images, called tdst im_fds ft.txt (do not edit this file),

● a helper script called look _t tdst im_fds ft.m,

● a helper script called dⅤ_lu_td cdtdbtions on tdst.m (do not edit this file), and

● a helper script called voc_p.m (do not edit this file).

1.  Get familiar with the test set, and how bounding boxes work, by exploring look _t tdst im_fds ft.m.

2.  [5 points]   Write a single-scale sliding window face detector, using the SVM you trained in Part 1.   Use cdtdbt.m as your starting point. Evaluate your detector by calling dⅤ_lu_td cdtdbtions on tdst.m with the appropriate arguments.

3.  [10 points]   Upgrade your face detector so that it does not make overlapping predictions.   This is called non-maximum suppression.  Detectors typically yield multiple high scores over a region.  You want to report the single best bounding box per object.  Since only a single bounding box is reported in the ground truth, failure to do so will result in a reduction in the test accuracy score.  You may want to inspect the code in dⅤ_lu_td cdtdbtions on tdst.m to how to calculate area of intersection, and area of union.

4.  [10 points]  Upgrade your face detector so that it makes predictions at multiple scales.

5.  [5 points]  Use your face detector on bl_ss.jpf, and plot the bounding boxes on the image.

6.  [5 points] Write a script called cdtdbt summ_ry.m, which prints out a brief summary of your approach (using eprinte). Be sure to include your best accuracy on the test set, what you did to improve performance, and a brief qualitative evaluation of your performance on bl_ss.jpf.

Bonus points will be awarded to the top-performing classifiers on bl_ss.jpf. Secret ground-truth labels (bounding boxes for faces) have already been generated. Do not use bl_ss.jpf in anyway to train your detector. If you would like to compete for these points, include a single script called cdtdbt bl_ss e_bds.m which runs the full detection pipeline. This script should:

1. load your SVM from a saved file (my sⅤm.m_t),

2. generate features from the image at multiple scales,

3. classify the features,

4.  suppress overlapping detections,

5. generate an N × 4 matrix of bounding boxes called aaoxds, where N is the number of faces you detect,

6. generate an N × 1 matrix of SVM scores called boneicdnbds, and

7. plot the bounding boxes on the image.

The marker will run this script, followed by an evaluation script that will use your aaoxds and boneicdnbds to generate an average precision score. The top three performing groups will get points as follows:

1st place: 15 points,

Feel free to research ways to improve your detector’s performance, aside from inputting detections manually. For ex- ample, it may help to add new training data to the existing set (e.g., training data from another dataset or augmenting the existing set by applying image transformations to some subset of the images, such as left-right flipping), revise your training approach (e.g., use hard negative mining1) or add some colour cues to the feature vector. Good luck!