AlexKM commited on
Commit
ae36220
1 Parent(s): ad09a46

Upload zoom.sh

Browse files
Files changed (1) hide show
  1. zoom.sh +35 -0
zoom.sh ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Example "Zoom" movie generation
3
+ # e.g. ./zoom.sh "A painting of zooming in to a surreal, alien world" Zoom.png 180
4
+
5
+ TEXT="$1"
6
+ FILENAME="$2"
7
+ MAX_EPOCHS=$3
8
+
9
+ LR=0.1
10
+ OPTIMISER=Adam
11
+ MAX_ITERATIONS=25
12
+ SEED=`shuf -i 1-9999999999 -n 1` # Keep the same seed each epoch for more deterministic runs
13
+
14
+ # Extract
15
+ FILENAME_NO_EXT=${FILENAME%.*}
16
+ FILE_EXTENSION=${FILENAME##*.}
17
+
18
+ # Initial run
19
+ python generate.py -p="$TEXT" -opt="$OPTIMISER" -lr=$LR -i=$MAX_ITERATIONS -se=$MAX_ITERATIONS --seed=$SEED -o="$FILENAME"
20
+ cp "$FILENAME" "$FILENAME_NO_EXT"-0000."$FILE_EXTENSION"
21
+ convert "$FILENAME" -distort SRT 1.01,0 -gravity center "$FILENAME" # Zoom
22
+ convert "$FILENAME" -distort SRT 1 -gravity center "$FILENAME" # Rotate
23
+
24
+ # Feedback image loop
25
+ for (( i=1; i<=$MAX_EPOCHS; i++ ))
26
+ do
27
+ padded_count=$(printf "%04d" "$i")
28
+ python generate.py -p="$TEXT" -opt="$OPTIMISER" -lr=$LR -i=$MAX_ITERATIONS -se=$MAX_ITERATIONS --seed=$SEED -ii="$FILENAME" -o="$FILENAME"
29
+ cp "$FILENAME" "$FILENAME_NO_EXT"-"$padded_count"."$FILE_EXTENSION"
30
+ convert "$FILENAME" -distort SRT 1.01,0 -gravity center "$FILENAME" # Zoom
31
+ convert "$FILENAME" -distort SRT 1 -gravity center "$FILENAME" # Rotate
32
+ done
33
+
34
+ # Make video - Nvidia GPU expected
35
+ ffmpeg -y -i "$FILENAME_NO_EXT"-%04d."$FILE_EXTENSION" -b:v 8M -c:v h264_nvenc -pix_fmt yuv420p -strict -2 -filter:v "minterpolate='mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps=60'" video.mp4