How to change the output label of a pretrained model.

조회 수: 1 (최근 30일)
Deng
Deng 2023년 2월 2일
댓글: Deng 2023년 2월 2일
I have a pretrained model from 'https://ssd.mathworks.com/supportfiles/vision/data/deeplabv3plusResnet18CamVid.zip'.
How could I change the output label from 11 labels, including "Sky, Building, Pole, Road, Pavement, SignSymbol, Tree, Fence, Car, Pedestrain, Bicyclist" into 5 labels, including "Vehicles, Bicycles and motorcycles, Pedestrians, Drivable surface, Others",
while "Vehicles" contains "Car", "Bicycles and motorcycles" contains "Bicyclists", "Pedestrians" contains "Pedestrian", "Drivable surface" contains "Road", "Others" contains "Sky, Building, Pole, Pavement, SignSymbol, Tree, Fence";

답변 (1개)

Aritra
Aritra 2023년 2월 2일
Hi, 
As per my understanding you are trying to change the output label of a pretrained model.
Pretrained models are read only so it’s not possible to change the output class names of a pretrained model directly. However, you can extract the output labels of a pretrained model store it in a table variable and can perform the required modifications. To do so you can take help of the below code snippet:
Network = load('deeplabv3plusResnet18CamVid.mat');
T1 = Network.metrics;
T2 = T1.ClassMetrics;
T2.Row(9) = cellstr("Vehicles");
You can refer to the MATLAB documentation for more details on cellstr:
  댓글 수: 1
Deng
Deng 2023년 2월 2일
Hi,
Thank you for your answer.
It resolutely solves part of my problem. The other one that bothered me is that what should I do if I want to combine several original categories into one new category (or just combine their data)? There are 11 labels in the original model, and I have only 5 categories, one of which contains the original seven categories which is like:
"Others" contains "Sky"," Building"," Pole", "Pavement", "SignSymbol", "Tree", and "Fence";

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 C4ISR에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by