Skip to content

robotic-vision-lab/Edge-Informed-Contrast-Maximization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Secrets of Edge-Informed Contrast Maximization (EINCM) for Event-Based Vision

[Paper - CVF] [Paper + Supplementary Material (preprint)- arXiv] [Oral Presentation] [Poster]


Overview

This repository provides source code for our 2025 WACV paper titled "Secrets of Edge-Informed Contrast Maximization for Event-Based Vision." Our paper extends the uni-modal contrast maximization to a bi-modal contrastcorrelation maximization. EINCM produces superior sharpness scores and establishes state-of-the-art event optical flow benchmarks on publicly available datasets.

Authors

  • Pritam P. Karmokar
  • Quan H. Nguyen
  • William J. Beksi

Citation

If you find this project useful, then please consider citing our work.

@inproceedings{karmokar2025secrets,
    author={Karmokar, Pritam P. and Nguyen, Quan H. and Beksi, William J.},
    title={Secrets of Edge-Informed Contrast Maximization for Event-Based Vision},
    booktitle={Proceedings of the Winter Conference on Applications of Computer Vision (WACV)},
    year={2025},
    pages={630--639},
    doi={10.1109/WACV61041.2025.00071}
}

Code Setup

Conda Environment

Create a virtual environment using conda:

# create the environment 
conda create -n eincm-env python=3.11

# activate the environment
conda activate eincm-env

# make sure pip is installed within the environment
conda install pip

With the virtual environment activated, move on to installing the pip packages.

Pip Packages

Linux would be the best option for working with JAX! At the time of development, JAX GPU was not supported on Windows natively (only through WSL). We strongly recommend using JAX GPU.

  1. Install JAX (please follow the instructions to install it successfully):
    pip install -U "jax[cuda12]"
  2. Install JAXopt and read the next section about adding a patch to the jaxopt source code locally:
    pip install jaxopt
  3. Install h5py and hdf5plugin:
    pip install h5py hdf5plugin
  4. Install OpenCV:
    pip install opencv-python opencv-contrib-python
  5. Install omegaconf and hydra:
    pip install omegaconf hydra-core
  6. Install the following additional packages:
    pip install easydict flow-vis imageio matplotlib numpy scikit-image scipy rich termcolor tqdm

JAX Source Code Edit

scipy_callback is the callback function that Scipy will receive. If Scipy's call wrapper sees the attribute intermediate_result in the signature of the callback function callback, then it will preserve the OptimizeResult wrapper around callback's argument, res, and call the callback function in keyword argument form callback(intermediate_result=res). Otherwise, it calls callback as callback(np.copy(res.x)).

Most minimizers, including BFGS, pass callback, an OptimizeResult object with attributes x and fun assigned with the intermediate (k-th iteration) param and objective value, respectively. The jaxopt ScipyWrapper may not account for this detail. Therefore, a small patch in the jaxopt source code is needed to accommodate this function to make the intermediate loss values available in EINCM's callbacks.

Go to jaxopt._src.scipywrapper.py around line 325-328 (might be version dependent), and find the scipy_callback function:

325 def scipy_callback(x_onp: onp.ndarray):
326   x_jnp = onp_to_jnp(x_onp)
327   return self.callback(x_jnp)

and replace it with the following:

325 def scipy_callback(intermediate_result: osp.optimize.OptimizeResult):
326   intermediate_result.x = onp_to_jnp(intermediate_result.x)
327   return self.callback(intermediate_result)
328 # def scipy_callback(x_onp: onp.ndarray):
329 #   x_jnp = onp_to_jnp(x_onp)
330 #   return self.callback(x_jnp)

Running Experiments

EINCM experiments are designed as Python packages. To run an experiment, navigate to src/ directory. Next, specify the package using namespace scoping (e.g., experiments.e00) and run it as a module (with python -m). For instance:

cd /path/to/src
python -m experiments.e00

This will run the __main__.py module within experiments.e00. To enable flexibility in how configs are inputted, the experiment expects configs to be provided explicitly through command line:

cd /path/to/src
python -m experiments.e00 --config-dir="path/to/config/direcory" --config-name="<name-of-config-yaml-file>"

# For example:
#  python -m experiments.e00 --config-dir="./experiments/e00/config" --config-name=main
#  OR
#  python -m experiments.e00 --config-path="./configs" --config-name=main
# 
# Note:
# -----
# If relative paths are used, the args config-dir and config-path presume different current working directories.

Alternatively, you may make use of the bash script run.sh (needs execute permissions chmod +x run.sh).

For more details on running the experiment under different configurations go to experiments/e00/.

License

License

About

Secrets of edge-informed contrast maximization for event-based vision.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published