File size: 1,652 Bytes
f0e9666
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash

# Folder paths
video_folder_path='./input/video'
txt_file_path='./input/text/prompt.txt'

# Get all .mp4 files in the folder using find to handle special characters
mapfile -t mp4_files < <(find "$video_folder_path" -type f -name "*.mp4")

# Print the list of MP4 files
echo "MP4 files to be processed:"
for mp4_file in "${mp4_files[@]}"; do
    echo "$mp4_file"
done

# Read lines from the text file, skipping empty lines
mapfile -t lines < <(grep -v '^\s*$' "$txt_file_path")

# List of frame counts
frame_length=32

# Debugging output
echo "Number of MP4 files: ${#mp4_files[@]}"
echo "Number of lines in the text file: ${#lines[@]}"

# Ensure the number of video files matches the number of lines
if [ ${#mp4_files[@]} -ne ${#lines[@]} ]; then
    echo "Number of MP4 files and lines in the text file do not match."
    exit 1
fi

# Loop through video files and corresponding lines
for i in "${!mp4_files[@]}"; do
    mp4_file="${mp4_files[$i]}"
    line="${lines[$i]}"
    
    # Extract the filename without the extension
    file_name=$(basename "$mp4_file" .mp4)
    
    echo "Processing video file: $mp4_file with prompt: $line"
        
    # Run Python script with parameters
    python \
        ./video_super_resolution/scripts/inference_sr.py \
        --solver_mode 'fast' \
        --steps 15 \
        --input_path "${mp4_file}" \
        --model_path /mnt/bn/videodataset/VSR/pretrained_models/STAR/model.pt \
        --prompt "${line}" \
        --upscale 4 \
        --max_chunk_len ${frame_length} \
        --file_name "${file_name}.mp4" \
        --save_dir ./results
done

echo "All videos processed successfully."