UGATIT pipeline

This commit is contained in:
2020-08-28 08:15:29 +08:00
parent 09db0a413f
commit 42d6253a1d
5 changed files with 211 additions and 4 deletions

20
tool/generate_video.sh Normal file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -o noclobber
set -o errexit # Used to exit upon error, avoiding cascading errors
set -o pipefail # Unveils hidden failures
set -o nounset # Exposes unset variables
pt=${1}
pt=${pt//[[:black:]]/}
output_dir=/tmp/frames
# .rm -rf $output_dir && /run.sh configs/synthesizers/UGATIT.yml test 0 resume_from=${pt} img_output_dir=${output_dir}
ids=$(ls ${output_dir} | cut -d "@" -f 1 | uniq)
mkdir tmp
for id in $ids; do
echo $id
ffmpeg -y -i "${output_dir}/${id}@%d.png" -vcodec mpeg4 tmp/${id}.mp4
# ffmpeg -y -f image2 -i "${output_dir}/${id}@%d.png" tmp/${id}.gif;
done

View File

@@ -0,0 +1,47 @@
#!/usr/bin/env bash
META_FILE="/data/VoxCeleb2/vox2_meta.csv"
VOX2_TEST_PATH="/data/VoxCeleb2/test/mp4/"
VOX2_DEV_PATH="/data/VoxCeleb2/dev/mp4/"
generate_frame() {
clip_path=$1
save_path=$3
fn="${clip_path##$2}"
fn=${fn//\//-}
ffmpeg -hide_banner -loglevel panic -threads 8 -i "$clip_path" -vf select="'eq(pict_type\,I)'" -vsync 2 -f image2 "$save_path${fn%.mp4}_%d.jpg" &>>ff.log
gnum=$(ls $save_path${fn%.mp4}_* | wc -l)
if [ $gnum -eq 0 ]; then
echo $clip_path >>"not_done.txt"
echo $clip_path ERROR
else
echo $clip_path >>"done.txt"
fi
}
iter_videos() {
idl=$1
root=$2
save_path=$3
cat "$idl" | wc -l
while read -u 10 pid; do
echo $pid
for vp in $root$pid/*/; do
num=$(ls $vp | wc -l)
if [ $num -ge 4 ]; then
echo $vp
for cp in $vp*.mp4; do
generate_frame "$cp" "$root" "$save_path"
done
fi
done
done 10<"$idl"
}
cat $META_FILE | grep f | grep dev | grep -Po "id[0-9]+" >f_dev.txt
cat $META_FILE | grep f | grep test | grep -Po "id[0-9]+" >f_test.txt
iter_videos f_dev.txt $VOX2_DEV_PATH "temp/dev/"
iter_videos f_test.txt $VOX2_TEST_PATH "temp/test/"