Computer Vision News - August 2022

13 Detect Graphic Intensity and Power in Videos Split the dataset into a training set and test set We are going to split the dataset into a training set and testing. The training set is used to train the model and the test set to check the model accuracy. training_set = int(len(names)*0.8) test_set = int(len(names)*0.2) names_training = names[0:training_set] names_test = names[training_set:] labels_training = labels[0:training_set] labels_test = labels[training_set:] Then we are going to process all video frames through VGG16 and save the transfer values. make_files(training_set); make_files_test(test_set) Load the cached transfer values into memory We have already saved all the video transfer values on disk. But we have to load those transfer values into memory to train the LSTM net. One question would be: why not process transfer values and load them into RAM? Yes is a more efficient way to train the second net. But if you have to train the LSTM in different ways to see which way gets the best accuracy, if you didn't save the transfer values on disk you would have to process the whole videos each training. It's very time-consuming processing the videos through VGG16 net. To load the saved transfer values into RAM we are going to use these two functions: def process_alldata_training(): joint_transfer=[] frames_num=20 count = 0 with h5py.File('prueba.h5', 'r') as f: X_batch = f['data'][:] y_batch = f['labels'][:] for i in range(int(len(X_batch)/frames_num)): inc = count+frames_num joint_transfer.append([X_batch[count:inc],y_batch[count]]) count =inc data =[] target=[] for i in joint_transfer: data.append(i[0]) target.append(np.array(i[1])) return data, target def process_alldata_test(): joint_transfer=[] frames_num=20 count = 0

RkJQdWJsaXNoZXIy NTc3NzU=