Skip to content

aamodbhatt/cycleflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CycleFlow-Inpaint

Project Description

CycleFlow-Inpaint is a research prototype for flow-guided video inpainting with cycle-consistent temporal optimization. It allows users to upload a video, draw a mask over an object, optionally enter a prompt, and remove or replace the object.

Research Motivation

Removing or replacing objects in videos often leads to temporal flickering and inconsistencies. This project implements a cycle-consistent self-supervised optimization approach. By enforcing that propagating an inpainted frame forward and backward should match the original inpainted frame, we drastically reduce temporal flickering without requiring large 3D models.

Architecture Diagram

graph TD
    A[Video] --> B[Frame Extraction]
    B --> C[Optical Flow RAFT]
    C --> D[Flow-guided Propagation]
    D --> E[Diffusion Inpainting]
    E --> F[Cycle-consistency Optimization]
    F --> G[Temporal Smoothing]
    G --> H[Final Video]
Loading

Pipeline Explanation

  1. Frame Extraction: Extract frames from the input video.
  2. Optical Flow: Use RAFT to compute forward and backward optical fields between consecutive frames.
  3. Flow-guided Propagation: Propagate masks and context to align sequences.
  4. Diffusion Inpainting: Apply Stable Diffusion 1.5 tailored for preserving original content and seamlessly painting masked regions.
  5. Cycle Optimization: A localized optimization loop modifies only masked pixels to ensure temporal consistency (backward(forward(frame)) ≈ frame).
  6. Smoothing: A temporal median filter reduces remaining noise.

Hardware Compatibility

The backend automatically detects the best hardware and adapts its configuration:

  • CUDA: 512px resolution, 15 optimization steps
  • MPS (Apple Silicon): 512px resolution, 10 optimization steps
  • CPU: 384px resolution, 5 optimization steps

Installation Instructions

# Clone the repository
git clone https://github.com/yourusername/cycleflow-inpaint.git
cd cycleflow-inpaint

# Run the setup script to install dependencies
bash scripts/setup.sh

Example Usage

  1. Start the backend:
python scripts/start_backend.py
  1. Start the frontend:
cd frontend
npm run dev
  1. Open http://localhost:3000 to interact with the web interface.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors