This project demonstrates video processing techniques including:
- Optical Flow Estimation: Calculates motion between video frames.
- Frame Interpolation: Generates an intermediate frame (frame1) between two input frames (frame0 and frame2) using optical flow and warping.
- Flow Regularization: Improves the quality of estimated optical flow fields.
- Super-Resolution: Enhances the resolution of the generated intermediate frame.
The primary script main_infer.py
orchestrates these processes.
- Python 3.x (tested with Python 3.9)
- A virtual environment is recommended.
-
Clone the repository (if applicable) or ensure you have the project files.
-
Create and activate a virtual environment:
python3 -m venv venv # you don't have to do this line if you have built the env before. source venv/bin/activate # do this line directly if you have built the env
(On Windows, use
venv\Scripts\activate
) -
Install the required Python packages:
pip install -r requirements.txt
-
Prepare Input Data:
- Place your input frames (e.g.,
frame0.png
,frame2.png
, and optionallyframe1.png
for evaluation) in a directory. The script currently expects them indata/public/
. You can modify the paths inmain_infer.py
if needed.
- Place your input frames (e.g.,
-
go to your branch
git pull git checkout your_branch
-
Run the main script:
python main_infer.py
-
Deactivate the virtual environment when done:
deactivate
- Set up
bash gpu_for_mac.sh
- Run train
bash train_for_mac.sh
- To log out
conda deactivate
deactivate
- To not let the colab disconnect
function ClickConnect(){
console.log("Working");
document.querySelector("colab-toolbar-button").click();
}
setInterval(ClickConnect, 60000);
The script will generate the following files in the output/
directory:
frame1_pred_regularized.png
: The super-resolved interpolated frame (predicted frame1).
main_infer.py
: The main script to run the inference pipeline.requirements.txt
: Lists Python package dependencies.models/
: Directory containing the core processing modules:__init__.py
: Makesmodels
a Python package.optical_flow.py
: Containsestimate_flow
for optical flow calculation.fusion.py
: Containswarp_frame
andfuse_frames
for frame interpolation.super_resolution.py
: Containsupscale
for increasing frame resolution.flow_regularization.py
: Containsregularize_flow_field
for improving flow quality.
utils/
: Directory for utility functions:__init__.py
: Makesutils
a Python package.metrics.py
: Containscompute_psnr_ssim
for evaluating image quality.
data/
: (Assumed) Directory for input data.public/
: (Assumed) Sub-directory for specific datasets likeframe0.png
,frame1.png
,frame2.png
.
output/
: Directory where processed images are saved.venv/
: (If created) Python virtual environment directory.
- add a new folder
module
add put your module into it - direct the output of the module into optical_flow.py
- make it able to do the rest of the work