Beispiel #1
0
def predictVideoGeneral(video_file, video_path, name_model, save_path, model_path, model_folder, img_height, img_width):
    video_title = os.path.splitext(video_file)[0]
    #img_size = 90

    vp.extractFaceImages(video_file, video_path)

    face_images = vp.loadFaceImages(video_file,video_path)

    labels, confidence = vp.predictVideo(face_images,name_model,img_height,img_width, DEFAULT_EXPR, model_path, model_folder) # Predict the facial expression label for each of the face images (that is, for each video frame)
#print 'Predicted labels: '+str(labels)
    clean_labels = vp.cleanLabels(labels)
#print 'Cleaned labels: '+str(clean_labels)

    perframe_labels_areStored = vp.savePredictionsPerFrame(clean_labels, save_path + video_title + '_predictions_perframe.csv')
    print perframe_labels_areStored

    perexp_labels_areStored = vp.savePredictionsPerExpression(clean_labels, save_path + video_title + 'predictions_perexp.csv')
    print perexp_labels_areStored

    # Play the tested video with the labels written in text format over the image
    vp.playLabeledVideo(video_path,video_file, clean_labels, True)

    # Clean all the files created by OpenFace
    vproc.deleteProcessData(video_path)
    
    return clean_labels
Beispiel #2
0
def confidenceLevelsVideoSetDefault(videos_path,nmodel):
    # Get the list of names of the video files
    classes = ['concerned','enthusiastic','neutral']
    model_path = 'defaultmodels/'
    img_height = 90
    img_width = 90
    videosList = os.listdir(videos_path) # Lists all files (and directories) in the folder
    confidence_videoset = []

    for video in videosList:
        if os.path.isfile(os.path.join(videos_path, video)): # Considers files only
            vp.extractFaceImages(video, videos_path)
    for video in videosList:
        if os.path.isfile(os.path.join(videos_path, video)):
            #extractFaceImages(video, videos_path)
            face_images = vp.loadFaceImages(video,videos_path)
            print 'Current video: '+str(video)
            labels, confidence = vp.predictVideo(face_images,'face-exp-model'+str(nmodel),img_height,img_width, DEFAULT_EXPR, model_path, models[nmodel]) # Run the model
            confidence_videoset.append([video]+confidence) # Store the mean and standard deviation of the per-frame confidence levels, representative of confidence of full video
    
    sorted(confidence_videoset, key=lambda x: x[1]) # Sort them per ascending mean value
    # The video(s) with the lowest confidence level are considered relevant for the model
    # (and hence will later be annotated and the model re-trained)

    for video in confidence_videoset: # Print the confidence levels of all videos, in ascending order
        print str(video[0])+" -- "+"mean cnf: "+str(video[1])+", stddev conf: "+str(video[2])
        
    # Clean all the files created by OpenFace
    vproc.deleteProcessData(videos_path)
Beispiel #3
0
 def videoSetProcessing(self, annot_type):
     if annot_type==0: # MMI-based annotations format
         vproc.videoProcessorMMI(self._data_path, self._list_classes)
     elif annot_type==1: # TT-based annotations format
         vproc.videoProcessor(self._data_path, self._list_classes)
     else:
         print 'WARNING: wrong annotation type code, videos could not be processed'
     vproc.deleteProcessData(self._data_path+'videos/')
Beispiel #4
0
def predictVideoSetDefault(videos_path, nmodel, save_path):
    videosList = os.listdir(videos_path) # Lists all files (and directories) in the folder

    for video in videosList:
        if os.path.isfile(os.path.join(videos_path, video)):
            labels = predictVideoDefault(video, videos_path, nmodel, save_path)
    
    # # Clean all the remaining files created by OpenFace
    vproc.deleteProcessData(videos_path)
Beispiel #5
0
 def verifyVideoQuality(self, video_path, video_file):
     os.system('./faceDetectorExtraction.sh '+video_file+' '+video_path)
     video_name = os.path.splitext(video_file)[0]
     videoPassesTest, cause = qver.verifyQuality(video_path, video_name)
     if videoPassesTest!=True:
         print 'The video passed the quality verification test'
     else:
         print 'The video did not pass the quality verification test -- reason: '+cause
     vproc.deleteProcessData(video_path)
Beispiel #6
0
    def predictVideoSetCustom(self, videos_path, model_name, save_path, input_type):
        model_path = self._data_path+'models/saved/'
        model_folder = model_name+'/'
        videosList = os.listdir(videos_path) # Lists all files (and directories) in the folder

        img_width = 90
        if input_type == dataset.INPUT_FULLFACE:
            img_height = 90
        else:
            img_height = 30

        for video in videosList:
            if os.path.isfile(os.path.join(videos_path, video)):
                predictVideoGeneral(video, videos_path, model_name, save_path, model_path, model_folder, img_height, img_width)
        
        # # Clean all the remaining files created by OpenFace
        vproc.deleteProcessData(videos_path)
Beispiel #7
0
 def verifyVideoSetQuality(self):
     qver.runQualityVerification(self._data_path+'videos/',self._data_path+'discarded_videos.txt')
     vproc.deleteProcessData(self._data_path+'videos/')