Məhsul kodu: 5056
% Using pre-trained ResNet-18 net = resnet18; lgraph = layerGraph(net); lgraph = removeLayers(lgraph, 'fc1000', 'prob', 'ClassificationLayer_predictions'); newLayers = [ fullyConnectedLayer(2, 'Name', 'fc_new') softmaxLayer('Name', 'softmax') classificationLayer('Name', 'classout')]; lgraph = addLayers(lgraph, newLayers); lgraph = connectLayers(lgraph, 'pool5', 'fc_new'); % Train on retinal dataset (1000 images/class) options = trainingOptions('sgdm', 'InitialLearnRate', 1e-4, 'MaxEpochs', 20); trainedNet = trainNetwork(augmentedTrainSet, lgraph, options);
% Load pre-trained VDSR network net = vdsrNetwork; % Low-resolution image lrImage = imresize(highResImage, 0.25); lrImage = imresize(lrImage, size(highResImage));
% Load and preprocess images imds = imageDatastore('image_folder', 'IncludeSubfolders', true, 'LabelSource', 'foldernames'); [imdsTrain, imdsValidation] = splitEachLabel(imds, 0.7, 'randomized'); % Define CNN architecture layers = [ imageInputLayer([64 64 3]) convolution2dLayer(3, 8, 'Padding', 'same') batchNormalizationLayer() reluLayer() maxPooling2dLayer(2, 'Stride', 2) fullyConnectedLayer(2) softmaxLayer() classificationLayer()];
% Train net = trainNetwork(imds, pxds, lgraph, options);
% Load pre-trained detector (requires Deep Learning Toolbox) detector = yolov2ObjectDetector('tiny-yolov2-coco'); % Read image I = imread('street_scene.jpg');
% Segment new image C = semanticseg(I, net); B = labeloverlay(I, C); imshow(B); Goal: Remove noise from images (medical MRI, low-light photography).
% Denoise denoisedImgs = predict(autoenc, noisyImgs); Goal: Increase image resolution while preserving details.
% Predict pred = classify(net, imdsValidation); accuracy = mean(pred == imdsValidation.Labels); disp(['Accuracy: ', num2str(accuracy)]); Goal: Locate and classify multiple objects within an image.
% Train network options = trainingOptions('adam', 'Plots', 'training-progress'); net = trainNetwork(imdsTrain, layers, options);
% Detect objects [bboxes, scores, labels] = detect(detector, I);
map = gradCAM(net, I, classIdx); imshow(I); hold on; imagesc(map, 'AlphaData', 0.5); Problem: Detect diabetic retinopathy from fundus images. Solution: CNN classifier + heatmap localization.
% Prepare noisy-clean pairs noisyImgs = imnoise(cleanImgs, 'gaussian', 0, 0.01); % Build autoencoder hiddenSize = 100; autoenc = trainAutoencoder(noisyImgs, hiddenSize, ... 'EncoderTransferFunction', 'satlin', ... 'DecoderTransferFunction', 'purelin', ... 'L2WeightRegularization', 0.001);
% Using pre-trained ResNet-18 net = resnet18; lgraph = layerGraph(net); lgraph = removeLayers(lgraph, 'fc1000', 'prob', 'ClassificationLayer_predictions'); newLayers = [ fullyConnectedLayer(2, 'Name', 'fc_new') softmaxLayer('Name', 'softmax') classificationLayer('Name', 'classout')]; lgraph = addLayers(lgraph, newLayers); lgraph = connectLayers(lgraph, 'pool5', 'fc_new'); % Train on retinal dataset (1000 images/class) options = trainingOptions('sgdm', 'InitialLearnRate', 1e-4, 'MaxEpochs', 20); trainedNet = trainNetwork(augmentedTrainSet, lgraph, options);
% Load pre-trained VDSR network net = vdsrNetwork; % Low-resolution image lrImage = imresize(highResImage, 0.25); lrImage = imresize(lrImage, size(highResImage));
% Load and preprocess images imds = imageDatastore('image_folder', 'IncludeSubfolders', true, 'LabelSource', 'foldernames'); [imdsTrain, imdsValidation] = splitEachLabel(imds, 0.7, 'randomized'); % Define CNN architecture layers = [ imageInputLayer([64 64 3]) convolution2dLayer(3, 8, 'Padding', 'same') batchNormalizationLayer() reluLayer() maxPooling2dLayer(2, 'Stride', 2) fullyConnectedLayer(2) softmaxLayer() classificationLayer()];
% Train net = trainNetwork(imds, pxds, lgraph, options);
% Load pre-trained detector (requires Deep Learning Toolbox) detector = yolov2ObjectDetector('tiny-yolov2-coco'); % Read image I = imread('street_scene.jpg');
% Segment new image C = semanticseg(I, net); B = labeloverlay(I, C); imshow(B); Goal: Remove noise from images (medical MRI, low-light photography).
% Denoise denoisedImgs = predict(autoenc, noisyImgs); Goal: Increase image resolution while preserving details.
% Predict pred = classify(net, imdsValidation); accuracy = mean(pred == imdsValidation.Labels); disp(['Accuracy: ', num2str(accuracy)]); Goal: Locate and classify multiple objects within an image.
% Train network options = trainingOptions('adam', 'Plots', 'training-progress'); net = trainNetwork(imdsTrain, layers, options);
% Detect objects [bboxes, scores, labels] = detect(detector, I);
map = gradCAM(net, I, classIdx); imshow(I); hold on; imagesc(map, 'AlphaData', 0.5); Problem: Detect diabetic retinopathy from fundus images. Solution: CNN classifier + heatmap localization.
% Prepare noisy-clean pairs noisyImgs = imnoise(cleanImgs, 'gaussian', 0, 0.01); % Build autoencoder hiddenSize = 100; autoenc = trainAutoencoder(noisyImgs, hiddenSize, ... 'EncoderTransferFunction', 'satlin', ... 'DecoderTransferFunction', 'purelin', ... 'L2WeightRegularization', 0.001);