keras-video-generators
keras-video-generators copied to clipboard
How to get y_true from the generator?
How to get y_true from the generator?
my_generator.classes return only the names of the classes, not the y_true.
I have exactly the same question.. I am using this for regression on video based dataset. So i also want to have the y_true values for each frame of my video. How can i get that from the generator ??
Hello, Not sure if this is the best way to do it but is working for me (at least until I find it doesn't). My x_gen var is the generator of my test split. BATCH_SIZE var is the batch size (obviously) that I used when creating the generator, as an argument.
#Get labels
y_test = []
for x in range(x_gen.__len__()):
#position [1] for labels
batch = x_gen.__getitem__(x)[1]
for y in range(BATCH_SIZE):
y_test.append(batch[y])
#Get labels indices
y_test = np.argmax(y_test, axis=1)
(if there is something wrong, please let me know hehe ) Hope it helps :)