필터 지우기
필터 지우기

Datastores for logical files when training mask R-CNN?

조회 수: 1 (최근 30일)
Alex
Alex 2023년 2월 21일
댓글: Clive Fox 2024년 4월 11일
When making training data for a Mask RCNN, you need the following things:
4 column cell array, where column 1 is an imageDatastore of the images, 2-3 is a boxLabelDatastore with bounding boxes and what they contain, and column 4, an imageDatastore with a logical array, each row Height x Width x Number of labels.
The first 3 are no problem, but number 4 vexes me. Here it suggests using poly2mask to generate the logical arrays, and a custom read function to put it into an imageDatastore, which to me feels like the ??? step in
1. Be poor. 2. ???, 3. Profit!
I've scoured the documentation and can find nothing about how to make matlab/imageDatastores manage logical arrays as images, or how to use it like a GroundTruth and get the file locations. I think I have an idea, but it seems so bulky and annoying, I hope there's a straightforward way.
My question:
If I have a folder My_Data, that only contains My_Sample_XXX.mat files which are Height x Width x Number of labels logical arrays, how do I get this into a datastore, like in the links?
  댓글 수: 1
Clive Fox
Clive Fox 2023년 4월 21일
I am having the exact same problem - please anyone got some suggestions?

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

채택된 답변

Clive Fox
Clive Fox 2023년 4월 21일
OK I think I found something which works
Don't the logical mask as a .mat file but as a binary.png
imwrite(mask_img,'mask_1.png'); where mask_img is the logical array
Then ...
mask_ds = imageDatastore('mask_1.png');
Seems to work so far.
  댓글 수: 1
Alex
Alex 2023년 4월 28일
This indeed seems to do the trick! Thank you so much!
For anyone in my exact situation, trying to get a maskRCNN to work:
  • I produced a GT with polygons
  • I used the usercreated function MPolyToMask + ImWrite (plus a function for adding the first polygon coordinate to the end of each polygon to "close the shape") to get data and images
  • For rectangles, I used my polygon coordinates and regionprops(CC,'BoundingBox'); to get those values and saved them in a table
This can be used to build the datastores.
Onwards to new roadblocks!

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

추가 답변 (1개)

Kevin Willeford
Kevin Willeford 2023년 9월 22일
Hi everyone,
I'm stuck on this one too. I have M X N X numObjects logical arrays. I only have two object categories per image; therefore, when I try to save the arrays as a .png, it doesn't work.
So, how to convert logical arrays with multiple objects per image into a datastore? The line saying "just create a custom read function" is baffling me.
  댓글 수: 2
Bryce
Bryce 2024년 2월 7일
Hey,
Did you figure it out?
Clive Fox
Clive Fox 2024년 4월 11일
See my solution above.

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

카테고리

Help CenterFile Exchange에서 Recognition, Object Detection, and Semantic Segmentation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by