This repository contains the code surrounding the Computational Photography course project aiming to automate the processingof DSLR-scanned film negatives.
.
├── data/ # Data storage and organization
│ ├── raw/ # Raw camera files (.RAF, .HIF)
│ ├── prepro/ # Pre-processed images
│ ├── datasets/ # Training/validation datasets
│ ├── checkpoints/ # Model checkpoints
│ └── reproduction/ # Reproduction assets
├── src/ # Source code
│ ├── nn/ # Machine Learning approach
│ │ ├── models/ # Neural network architectures
│ │ ├── utils/ # Training utilities and dataset loading
│ │ ├── eval/ # Evaluation and testing tools
│ │ └── data/ # Data handling
│ ├── scripts/ # Processing and utility scripts. Includes training scripts.
│ │ ├── sigmoid/ # Statistical sigmoid correction
│ │ ├── kp_calc/ # Tool to collect the color dataset by
│ │ └── train/ # Training scripts
│ ├── processing/ # Statistical image processing. Contains the Sigmoid correct code
│ ├── analysis/ # Analysis and visualization tools
│ ├── utils/ # General utilities
└── requirements.txt
The neural network pipeline provides end-to-end learning for film negative correction:
- The model architectures are located in src/nn/models (
one_hidden,enhanced_comb,combhidden) - Full training pipeline with validation and testing through the
main_trainer.pyscript (seesrc/scripts/trainingfor an example invocation)- Training in both RGB and LAB color spaces has been tested (can be switched with a flag)
- White Balance methods can be selected using the
WhiteBalanceclass (white_balance.py). - Hyper-parameter optimization (namely generating a PDF with various combinations of hyperparameters, which can be selected through a configuration file) through the
src/scripts/sigmoid/correct_many.py
Interactive GUI application for data collection and annotation
- Using image mappings, draw matching rectangles to select pixel regions across image sets
- Adapts based on image transforms
- Used to generate CSV datasets for training the NN models (see
--multipleand--data-processingflags)
Usage:
python src/scripts/kp_calc/app.py- Python 3.9+ (recommended 3.12+, tested with 3.10+)
- PyTorch if NN training(install according to your system: https://pytorch.org/get-started/locally/)
- exiftool (required for RAW file metadata extraction)
- Clone the repository:
git clone https://github.com/vigarov/positron
cd positron- Install dependencies:
pip install -r requirements.txt- Set up data directory structure (see
data/README.mdfor details)
- Data Collection: Use the interactive tool to collect training data
python src/scripts/kp_calc/kp_calc.py -h- Statistical Processing: Generate a PDF with applying the sigmoid correction method on all the images from the dataset
python src/scripts/sigmoid/correct_many.py -h- ML Training: Train a neural network model
Simply execute one of the trainers in src/scripts/train/ or run your own train by invoking the train loop:
python src/nn/main_trainer.py -h