Image Classification using Percentage

5 visualizzazioni (ultimi 30 giorni)
We are working on a project. The goal of the project is to calculate the ratio (in percentage) of musillage in photos. I successfully classified whether a phot has musillage or not (%0 or %100) but not any number in between. The photos are classified using image labeling. The code is attached, woul you please suggest how to improve the working code to cover the percentage of musillages. Two photos of both classes are attached.
Thanks in advance
++
clear all; clc;
imds = imageDatastore("C:\Users\fatih.yigit\OneDrive - ALTINBAS UNIVERSITY\Project 10\project10\Musillage_Photos", ...
IncludeSubfolders=true, ...
LabelSource="foldernames");
numTrainFiles = 25;
[imdsTrain,imdsValidation] = splitEachLabel(imds,numTrainFiles,"randomized");
classNames = categories(imdsTrain.Labels);
inputSize = [300 300 3];
numClasses = 2;
layers = [
imageInputLayer(inputSize)
convolution2dLayer(20,50)
batchNormalizationLayer
reluLayer
fullyConnectedLayer(numClasses)
softmaxLayer];
options = trainingOptions("sgdm", ...
MaxEpochs=50, ...
ValidationData=imdsValidation, ...
ValidationFrequency=30, ...
Plots="training-progress", ...
Metrics="accuracy", ...
Verbose=false);
net = trainnet(imdsTrain,layers,"crossentropy",options);
scores = minibatchpredict(net,imdsValidation);
YValidation = scores2label(scores,classNames);
++
  5 Commenti
Fatih
Fatih il 17 Feb 2025
Actually I labeled the mucillage regions manually using the image labeler.
Walter Roberson
Walter Roberson il 17 Feb 2025
imds = imageDatastore("C:\Users\fatih.yigit\OneDrive - ALTINBAS UNIVERSITY\Project 10\project10\Musillage_Photos", ...
IncludeSubfolders=true, ...
LabelSource="foldernames");
You are getting your labels from the foldernames, not from ground-truth labels.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 16 Feb 2025
classNames = categories(imdsTrain.Labels);
That tells us that the class names are categoricals. It is doubtful that the class names happen to be "000%", "001%", "002%" ... "010%", "011%" ... all the way to "099%" and "100%" -- you simply don't have enough training images to be that fine grained. If you do have numbered categories, it is more likely something like "0%", "10%", "20%", up to "90%" then "100%". But categories are internally ordered alphabetically rather than by extracting embedded numbers, so the order would more likely come out as "0%", "10%", "100%", "20%", "30%" up to "90%". The ordering is weak, and so cannot really be used predictively
Now, your images are not internally labeled as to whether parts are musillage or not, so the processing is free to pick out any part to focus on. The processing could, for example, end up focusing on "mountains" and end up ignoring the musillage.
  1 Commento
Fatih
Fatih il 17 Feb 2025
Actually I labeded photos using Imagelabeler while selecting musillage areas. They may not be perfect but gives an idea. So if there is better way, I am also comfortable to ignore what I did and start from scratch including more photos.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Image Data Workflows in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by