Can I give multiple labels to a single file in ImageDatastore

조회 수: 4 (최근 30일)
Andy Holmes-Evans
Andy Holmes-Evans 2019년 8월 7일
답변: Jayanti 2025년 4월 4일
Can I give multiple categorical labels to a single file in ImageDatastore. For example I have an outdoor photograph which contains a Dog, Tree and Sky. I have Inceptionv3 running in Python with all files in one directory, and the muliple labels held in txt files of same names and want to rebuild this in MATLAB. The only option I can find is ('LabelSouce','foldernames'). Is it possible to add multiple labels to a single file in the Datastore, or do I need to add the file 3 times, once for each label, or use a different method?
  댓글 수: 11
Ameetha
Ameetha 2023년 1월 25일
@Yousef Omar did you find any solution?
Ameetha
Ameetha 2023년 1월 25일
@Andy Holmes-Evans can you give the solution pls

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

답변 (1개)

Jayanti
Jayanti 2025년 4월 4일
Hi,
To assign multiple labels to a single image in MATLAB, you can use a combination of “imageDatastore” and “arrayDatastore”.
Start by preparing a cell array where each cell contains a categorical array of labels corresponding to each image. Create an “arrayDatastore” with this cell array. Use the “combine” function to merge the image and label datastores.
For example, if you have two images, you can set up the combined datastore as shown below:
labelCellArray = cell(2, 1);
labelCellArray{1} = categorical(["ball" "dog" "cat"]);
labelCellArray{2} = categorical(["tree" "sky"]);
labelDs = arrayDatastore(labelCellArray);
dsTrain = combine(imds, labelDs);
Hope this will be helpful!

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by