Harmonizing algorithms from bob.pad.face and bob.pad.voice, fixes issue#16
4 unresolved threads
4 unresolved threads
Merge request reports
Activity
- bob/pad/base/utils/helper_functions.py 0 → 100644
23 """ 24 25 feature_vectors = [] 26 27 frame_dictionary = {} 28 29 for frame in frame_container: 30 frame_dictionary[frame[0]] = frame[1] 31 32 for idx, _ in enumerate(frame_container): 33 # Frames are stored in a mixed order, therefore we get them using incrementing frame index: 34 feature_vectors.append(frame_dictionary[str(idx)]) 35 36 features_array = np.vstack(feature_vectors) 37 38 return features_array - bob/pad/base/utils/helper_functions.py 0 → 100644
82 83 ``features_array`` : 2D :py:class:`numpy.ndarray` 84 An array containing features for all frames of all individuals. 85 """ 86 87 feature_vectors = [] 88 89 for frame_container in frame_containers: 90 video_features_array = self.convert_frame_cont_to_array( 91 frame_container) 92 93 feature_vectors.append(video_features_array) 94 95 features_array = np.vstack(feature_vectors) 96 97 return features_array This is not memory friendly as it will create at least two copies of the data. It's better to use the function that I introduced in bob.bio.base for this: https://www.idiap.ch/software/bob/docs/bob/docs/master/bob.bio.base/doc/py_api.html#bob.bio.base.vstack_features
- bob/pad/base/algorithm/SVM.py 0 → 100644
583 584 data = [np.copy(real)] # only real class used for training 585 586 # free the memory of unnecessary data 587 del real 588 del attack 589 590 machine = trainer.train(data) # train the machine 591 592 if mean_std_norm_flag: 593 machine.input_subtract = features_mean # subtract the mean of train data 594 machine.input_divide = features_std # divide by std of train data 595 596 del data 597 598 return machine - bob/pad/base/utils/helper_functions.py 0 → 100644
210 for further details. Each frame container contains one feature vector. 211 """ 212 213 frame_container_list = [] 214 215 for idx, vec in enumerate(data): 216 217 frame_container = bob.bio.video.FrameContainer( 218 ) # initialize the FrameContainer 219 220 frame_container.add(0, vec) 221 222 frame_container_list.append( 223 frame_container) # add current frame to FrameContainer 224 225 return frame_container_list @amohammadi Baby steps. For now, I just copied stuff from
bob.pad.face
and at least moved some of the obvious generic functions to utils, since there is a lot of copy/paste going on inbob.pad.face
.Let me make it work first, then move the rest of the algorithms, then optimize.
It takes some effort to clear up all this mess.
mentioned in commit 91857aa2
Please register or sign in to reply