-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting_code.m
More file actions
29 lines (29 loc) · 894 Bytes
/
testing_code.m
File metadata and controls
29 lines (29 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
clc
clear all
close all
% Initialize Webcam
cam = webcam;
% Load Pretrained Model (Choose either Transfer Learning or Feature Extraction Approach)
load('netTransfer.mat'); % For Transfer Learning Approach
% or
load('mainmma.mat'); % For Feature Extraction Approach
% Main Loop
while true
% Capture Image from Webcam
img = snapshot(cam);
% Preprocess Image (Resize, Convert to Grayscale if needed, etc.)
% Example:
img = imresize(img, [227 227]); % Resize to fit AlexNet input size
% Classify Image Emotion
% For Transfer Learning Approach
predictedLabel = classify(netTransfer, img);
% or For Feature Extraction Approach
features = activations(net, img, 'fc7', 'OutputAs', 'rows');
predictedLabel = predict(classifier, features);
% Display Result
imshow(img);
title(['Predicted Emotion: ', char(predictedLabel)], 'FontSize', 14);
drawnow;
end
% Clean up
clear cam;