From 4f68fc1df943ca95c035840e9096ae6020d91a79 Mon Sep 17 00:00:00 2001 From: rudrabha Date: Sat, 3 Oct 2020 21:41:51 +0530 Subject: [PATCH] Added eval script for the real videos --- .../calculate_scores_real_videos.py | 45 +++++++++++++++++++ .../calculate_scores_real_videos.sh | 7 +++ 2 files changed, 52 insertions(+) create mode 100755 evaluation/scores_LSE/calculate_scores_real_videos.py create mode 100644 evaluation/scores_LSE/calculate_scores_real_videos.sh diff --git a/evaluation/scores_LSE/calculate_scores_real_videos.py b/evaluation/scores_LSE/calculate_scores_real_videos.py new file mode 100755 index 0000000..0962258 --- /dev/null +++ b/evaluation/scores_LSE/calculate_scores_real_videos.py @@ -0,0 +1,45 @@ +#!/usr/bin/python +#-*- coding: utf-8 -*- + +import time, pdb, argparse, subprocess, pickle, os, gzip, glob + +from SyncNetInstance_calc_scores import * + +# ==================== PARSE ARGUMENT ==================== + +parser = argparse.ArgumentParser(description = "SyncNet"); +parser.add_argument('--initial_model', type=str, default="data/syncnet_v2.model", help=''); +parser.add_argument('--batch_size', type=int, default='20', help=''); +parser.add_argument('--vshift', type=int, default='15', help=''); +parser.add_argument('--data_dir', type=str, default='data/work', help=''); +parser.add_argument('--videofile', type=str, default='', help=''); +parser.add_argument('--reference', type=str, default='', help=''); +opt = parser.parse_args(); + +setattr(opt,'avi_dir',os.path.join(opt.data_dir,'pyavi')) +setattr(opt,'tmp_dir',os.path.join(opt.data_dir,'pytmp')) +setattr(opt,'work_dir',os.path.join(opt.data_dir,'pywork')) +setattr(opt,'crop_dir',os.path.join(opt.data_dir,'pycrop')) + + +# ==================== LOAD MODEL AND FILE LIST ==================== + +s = SyncNetInstance(); + +s.loadParameters(opt.initial_model); +#print("Model %s loaded."%opt.initial_model); + +flist = glob.glob(os.path.join(opt.crop_dir,opt.reference,'0*.avi')) +flist.sort() + +# ==================== GET OFFSETS ==================== + +dists = [] +for idx, fname in enumerate(flist): + offset, conf, dist = s.evaluate(opt,videofile=fname) + print (str(dist)+" "+str(conf)) + +# ==================== PRINT RESULTS TO FILE ==================== + +#with open(os.path.join(opt.work_dir,opt.reference,'activesd.pckl'), 'wb') as fil: +# pickle.dump(dists, fil) diff --git a/evaluation/scores_LSE/calculate_scores_real_videos.sh b/evaluation/scores_LSE/calculate_scores_real_videos.sh new file mode 100644 index 0000000..bd02c95 --- /dev/null +++ b/evaluation/scores_LSE/calculate_scores_real_videos.sh @@ -0,0 +1,7 @@ +rm all_scores.txt +yourfilenames=`ls $1` +for eachfile in $yourfilenames +do + python run_pipeline.py --videofile $eachfile --reference wav2lip --data_dir tmp_dir + python calculate_scores_real_videos.py --videofile $eachfile --reference wav2lip --data_dir /ssd_scratch/cvit/prajwalkr_rudra/tmp_dir >> all_scores.txt +done