Skip to content

[CVPR'19, ICLR'20] A Python toolbox for modeling and optimization of photo acquisition & distribution pipelines (camera ISP, compression, manipulation detection)

Notifications You must be signed in to change notification settings

matchading/neural-imaging

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neural Imaging Toolbox

Authors: Paweł Korus and Nasir Memon, New York University

A Python toolbox for modeling and optimization of photo acquisition and distribution channels focusing on reliable manipulation detection capabilities. Joint optimization can include the camera ISP (NIP), lossy image compression (DCN), and forensic image analysis (FAN).

The toolbox provides a Tensorflow implementation of the following generic model:

training for optimized manipulation detection

More information can be found in papers listed below:

  1. P. Korus, N. Memon, Content Authentication for Neural Imaging Pipelines: End-to-end Optimization of Photo Provenance in Complex Distribution Channels, CVPR'19, arxiv:1812.01516
  2. P. Korus, N. Memon, Neural Imaging Pipelines - the Scourge or Hope of Forensics?, 2019, arXiv:1902.10707
  3. P. Korus, N. Memon, Quantifying the Cost of Reliable Photo Authentication via High-Performance Learned Lossy Representations, ICLR'20, openreview

A standalone version of our lossy compression codec can be found in the l3ic repository.

Change Log

  • 2019.12 - Added support for learned compression, configurable manipulations + major refactoring

Setup

The toolbox was written in Python 3. Follow the standard procedure to install dependencies.

> git clone https://github.com/pkorus/neural-imaging && cd neural-imaging
> pip3 install -r requirements.txt
> mkdir -p data/{raw,rgb}
> git submodule init
> cd pyfse && make && cd ..

Data Directory Structure

The toolbox uses the data directory to store images, training data and pre-trained models:

data/raw/                               - RAW images used for camera ISP training
  |- images/{camera name}                 RAW images (*.nef *.dng)
  |- nip_training_data/{camera name}      Bayer stacks (*.npy) and developed (*.png)
  |- nip_developed/{camera name}/{nip}    NIP-developed images (*.png)
data/rgb/                               - RGB images used for compression training
  |- kodak                                A sample dataset with kodak images
data/config                             - Training configuration files (e.g., DCN)
data/models                             - pre-trained TF models
  |- nip/{camera name}/{nip}              NIP models (TF checkpoints)
  |- dcn/{dcn model}                      DCN models (TF checkpoints)
data/m                                  - manipulation training results
data/results                            - CSV files with exported results

Getting Started

The model can be easily customized to use various NIP models, photo manipulations, distribution channels, etc. Detailed configuration instruction are given below. We generally follow a 2-step protocol with separate model pre-training (camera ISP, compression) and joint optimization/fine-tuning for manipulation detection (retraining from scratch is also possible, but has not been tested).

The following sections cover all training steps:

The optimization results are stored in JSON files (training.json) organized into a folder hierarchy (by default in data/m/*). The results can be quickly visualized using the results.py script.

Available Models

The framework provides:

The toolbox currently provides the following imaging pipelines:

Pipeline Description
libRAW uses the libRAW library to develop RAW images
Python simple Python implementation of a standard pipeline
INet simple NIP which mimics step-by-step processing of the standard pipeline
UNet the well known UNet network
DNet medium-sized model adapted from a recent architecture for joint demosaicing and denoising
ONet dummy pipeline for directly feeding RGB images into the workflow

The standard pipelines are available in the raw_api module. Neural pipelines are available in models/pipelines. The UNet model was adapted from Learning to See in the Dark.

Our neural image compression codec is an adaptation of the auto-encoder architecture proposed by Twitter (Theis et al., Lossy Image Compression with Compressive Autoencoders), and hence dubbed TwitterDCN (see models/compression.py). A standalone version is also available in the neural-image-compression repository.

Extending the Framework

The framework can be easily extended. See the extensions section for information how to get started.

If you would like to contribute new models, training protocols, or if you find any bugs, please let us know.

Script Summary

Script Description
develop_images.py batch rendering of RAW images using various camera ISPs
diff_nip.py compare RAW rendering results of two camera ISPs
results.py visualization of FAN optimization results
test_dcn.py test neural image compression / generate rate-distortion profiles
test_dcn_rate_dist.py plot rate-distortion (R/D) curves for neural image compression (requires pre-computing R/D profiles using test_dcn.py)
test_fan.py allows for testing trained FAN models on various datasets
test_framework.py a rudimentary test of the entire framework (see testing)
test_jpeg.py test differentiable approximation of the JPEG codec
test_nip.py test a pre-trained camera ISP
train_dcn.py pre-train lossy compression
train_manipulation.py optimization of the FAN (+NIP/DCN) for manipulation detection
train_nip.py pre-train camera ISPs
train_prepare_training_set.py prepare training data for camera ISP pre-training (imports RAW images)
summarize_nip.py extracts and summarizes performance stats for standalone NIP models

Data Sources

In our experiments we used RAW images from publicly available datasets:

Usage and Citations

This code is provided for educational purposes and aims to facilitate reproduction of our results, and further research in this direction. We have done our best to document, refactor, and test the code before publication. However, the toolbox is provided "as-is", without warranties of any kind.

If you find this code useful in your work, please cite our papers:

@inproceedings{korus2019content,
  title={Content Authentication for Neural Imaging Pipelines: End-to-end Optimization of Photo Provenance in Complex Distribution Channels},
  author={Korus, Pawel and Memon, Nasir},
  booktitle={IEEE Conf. Computer Vision and Pattern Recognition},
  year={2019}
}
@article{korus2019neural,
  title={Neural Imaging Pipelines - the Scourge or Hope of Forensics?},
  author={Korus, Pawel and Memon, Nasir},
  journal={arXiv preprint arXiv:1902.10707},
  year={2019}
}
@inproceedings{korus2020quantifying,
  title={Quantifying the Cost of Reliable Photo Authentication via High-Performance Learned Lossy Representations},
  author={Korus, Pawel and Memon, Nasir},
  booktitle={IEEE Conf. Learning Representations},
  year={2020}
}

Related Work

End-to-end ISP optimization:

Learned Compression

About

[CVPR'19, ICLR'20] A Python toolbox for modeling and optimization of photo acquisition & distribution pipelines (camera ISP, compression, manipulation detection)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 92.7%
  • Jupyter Notebook 5.9%
  • Shell 1.4%