コード例 #1
0
                accumulate_prob += ftrs[i*ftrs.shape[0]/5:(i+1)*ftrs.shape[0]/5,:]

            accumulate_prob = accumulate_prob/5.0
            log_observ_likelihood = log(accumulate_prob.T + numpy.finfo(numpy.float32).eps) 
        else:
            log_observ_likelihood = log(ftrs.T + numpy.finfo(numpy.float32).eps) 
        log_observ_likelihood[-1, 0:5] = 0
        log_observ_likelihood[-1, -5:] = 0

        print("\t Viterbi path decoding " )
        # do it in log space avoid numeric underflow
        [path, predecessor_state_index, global_score] = viterbi_path_log(log(Prior), log(Transition_matrix), log_observ_likelihood)
        #[path, predecessor_state_index, global_score] =  viterbi_path(Prior, Transition_matrix, observ_likelihood)
        
        # Some gestures are not within the vocabulary
        [pred_label, begin_frame, end_frame, Individual_score, frame_length] = viterbi_colab_clean(path, global_score, threshold=-100, mini_frame=19)

        #begin_frame = begin_frame + 1
        end_frame = end_frame + 5 # note here 3DCNN should add 5 frames because we used 4 frames
        ### plot the path and prediction
        if True:
            im  = imdisplay(global_score)
            plt.clf()
            plt.imshow(im, cmap='gray')
            plt.plot(range(global_score.shape[-1]), path, color='c',linewidth=2.0)
            plt.xlim((0, global_score.shape[-1]))
            # plot ground truth
            gesturesList=smp.getGestures()
            for gesture in gesturesList:
            # Get the gesture ID, and start and end frames for the gesture
                gestureID,startFrame,endFrame=gesture
コード例 #2
0
        #####################
        log_observ_likelihood = log(ftrs.T)
        log_observ_likelihood[-1, 0:5] = 0
        log_observ_likelihood[-1, -5:] = 0

        print("\t Viterbi path decoding ")
        # do it in log space avoid numeric underflow
        [path, predecessor_state_index,
         global_score] = viterbi_path_log(log(Prior), log(Transition_matrix),
                                          log_observ_likelihood)
        #[path, predecessor_state_index, global_score] =  viterbi_path(Prior, Transition_matrix, observ_likelihood)

        # Some gestures are not within the vocabulary
        [pred_label, begin_frame, end_frame, Individual_score,
         frame_length] = viterbi_colab_clean(path,
                                             global_score,
                                             threshold=-100,
                                             mini_frame=19)

        #begin_frame = begin_frame + 1
        end_frame = end_frame + 5  # note here 3DCNN should add 5 frames because we used 4 frames
        ### plot the path and prediction
        if False:
            im = imdisplay(global_score)
            plt.imshow(im, cmap='gray')
            plt.plot(range(global_score.shape[-1]),
                     path,
                     color='c',
                     linewidth=2.0)
            plt.xlim((0, global_score.shape[-1]))
            # plot ground truth
            gesturesList = smp.getGestures()
コード例 #3
0
            load_path_depth= os.path.join(outPred_depth,file)

            dic_cropped= cPickle.load( open(load_path_cropped, "rb" ) )
            dic_depth = cPickle.load( open(load_path_depth, "rb" ) )

            log_observ_likelihood_cropped= dic_cropped['log_observ_likelihood']
            log_observ_likelihood_depth = dic_depth['log_observ_likelihood']

            log_observ_likelihood = log_observ_likelihood_cropped + log_observ_likelihood_depth 
            print "Viterbi path decoding " + file
            # do it in log space avoid numeric underflow
            [path, predecessor_state_index, global_score] = viterbi_path_log(log(Prior), log(Transition_matrix), log_observ_likelihood)
            #[path, predecessor_state_index, global_score] =  viterbi_path(Prior, Transition_matrix, observ_likelihood)
        
            # Some gestures are not within the vocabulary
            [pred_label, begin_frame, end_frame, Individual_score, frame_length] = viterbi_colab_clean(path, global_score, threshold=-100, mini_frame=19)
            ### In theory we need add frame, but it seems that the groutnd truth is about 3 frames more, a bit random
            end_frame = end_frame + 3

            print "Elapsed time %d sec" % int(time.time() - time_tic)
            prediction=[]
            for i in range(len(begin_frame)):
                prediction.append([ pred_label[i], begin_frame[i], end_frame[i]] )

            if True:
                import matplotlib.pyplot as plt
                im  = imdisplay(global_score)
                plt.clf()
                plt.imshow(im, cmap='gray')
                plt.plot(range(global_score.shape[-1]), path, color='c',linewidth=2.0)
                plt.xlim((0, global_score.shape[-1]))