How to concatenate video frames into single matrix for cnn?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have multiple videos. Each video has different number of frames. I am trying to combine all the frames of all videos for training of CNN. But I faced errors.
댓글 수: 3
답변 (1개)
Siraj
2023년 8월 30일
Hii! It is my understanding that you want to read different videos corresponding to different English alphabets and then concatenate each frame of these videos to train a classification network.
You have attached 2 codes; I believe the second code is an improvement of the first and solves the error given by the first code but generates a new error.
In the code attached in the first comment, a video is being read and all the frames of that video are extracted and vertically concatenated in the “all_frames”. This makes “all_frames” a 3d array and this variable is then passed to “augmentedImageDatastore()” which expects a 4d array.
Refer to the input arguments of “augmentedImageDatastore()” below.
Another issue with the code attached in the first comment is that “sslbl” has only one category (1) but it should have exactly 2 categories (1,2) since you have mentioned “Total 4 videos. First 2 videos for'A' letter & remaining 2 are for 'B' letter.”
However, both above issues are fixed in the code attached in the second comment.
The new error that appears is
Error using trainNetwork (line 184)
Invalid validation data. The output size (26) of the last layer does not match the number
of classes (25).
Even though I am not able to reproduce this error at my end since I don’t have access to the data and helper functions “chk_fn”, “chk_letter_cnt_for_validation_AVLETTERS”, from the error message it is quite evident that “bb1” contains only 25 different categories instead of 26 different categories. This can be because of either “acnt” or “bct” …….or “zcnt” being 0.
Since you have not mentioned the “classes” while defining the classification layer so this parameter is set to “auto” and the number of classes will be defined at the time of training.
Refer to the document below to define the number of classes for a “classificationLayer”
To resolve the error, make sure that “bb1” has exactly 26 different categories.
Hope this helps.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!