#/usr/bin/bash

testcase=$1
datadir='data/__new/classroom_fovea_r360x80_t0.6'
trainset='data/__new/classroom_fovea_r360x80_t0.6/r120x80.json'
testset='data/__new/classroom_fovea_r360x80_t0.6/r120x80_test.json'
videoset='data/__new/classroom_fovea_r360x80_t0.6/helix.json'
epochs=50

# nets: 1, 2, 4, 8
# layers: 2, 4, 8
# channels: 64 128 256 512 1024
n_nets_arr=(1 2 4 8 1 2 4 8 1 2 4 8)
n_layers_arr=(2 2 2 2 4 4 4 4 8 8 8 8)
n_nets=${n_nets_arr[$testcase]}
n_layers=${n_layers_arr[$testcase]}

for nf in 64 128 256 512 1024; do
    configid="eval@snerffast${n_nets}-rgb_e6_fc${nf}x${n_layers}_d1.00-7.00_s64_~p"
    if [ ! -f "$datadir/$configid/model-epoch_$epochs.pth" ]; then
        cont_epoch=0
        for ((i=$epochs-1;i>0;i--)) do
            if [ -f "$datadir/$configid/model-epoch_$i.pth" ]; then
                cont_epoch=$i
                break
            fi
        done
        if [ ${cont_epoch} -gt 0 ]; then
            python run_spherical_view_syn.py $trainset -e $epochs -m $configid/model-epoch_${cont_epoch}.pth
        else
            python run_spherical_view_syn.py $trainset -i $configid -e $epochs
        fi
    fi
    if ! ls $datadir/$configid/output_$epochs/perf* >/dev/null 2>&1; then
        python run_spherical_view_syn.py $trainset -t -m $configid/model-epoch_$epochs.pth -o perf
        python run_spherical_view_syn.py $testset -t -m $configid/model-epoch_$epochs.pth -o perf
    fi
    if [ ! -d "$datadir/$configid/output_$epochs/r120x80_test_color" ]; then
        python run_spherical_view_syn.py $testset -t -m $configid/model-epoch_$epochs.pth -o color
    fi
    if [ ! -f "$datadir/$configid/output_$epochs/helix_color.mp4" ]; then
        python run_spherical_view_syn.py $videoset -t -m $configid/model-epoch_$epochs.pth -o color --output-type video
    fi
done