How xavysp/dexined works
Purpose and primary entry points
DexiNed is a CNN-based perceptual edge-detection project. The current implementation is PyTorch and supports both training and checkpoint-based inference through main.py. Inputs are images or dataset image/edge-label pairs; outputs are multi-scale/fused edge maps and saved evaluation artifacts.
Paths: main.py, model.py, data/lena_std.tif
Execution orchestration
main.py is the operational boundary: argument parsing selects test data and testing vs. training mode, obtains dataset metadata, builds data loaders/model/loss, and drives training or inference. Testing expects externally downloaded checkpoints in a prescribed checkpoints/... location.
Paths: main.py, datasets.py, losses.py
Dataset configuration and ingestion
Dataset identities and filesystem conventions are centralized in datasets.py, including BIPED as the training default and named benchmark/test sets. The loader layer converts images and edge annotations into model-ready tensors; the repository includes a CLASSIC-style sample-image path and an MDBD list example. Image dimensions must be multiples of 16 because of model downsampling.
Paths: datasets.py, dataset-lists/MDBD/test_pair.lst, data/lena_std.tif
DexiNed neural architecture
The PyTorch model is defined by the DexiNed class in model.py. It is a dense extreme-inception encoder/decoder-style edge detector that produces multiple side outputs plus a fused result, enabling deep supervision in a single training stage and inference-time edge prediction.
Paths: model.py, main.py
Training objective and optimization boundary
losses.py contains the BDCN-derived edge loss used to supervise the model’s multiple outputs against boundary labels. Training is from scratch rather than dependent on pretrained weights. The training loop and checkpoint lifecycle are controlled by main.py; checkpoint files are external runtime assets rather than repository contents.
Paths: losses.py, main.py
Image processing and result handling
Shared image-oriented operations are separated from the model and training orchestration in the utility package. These support preparation and/or serialization of visual edge-detection results. Existing res/ content is benchmark output, organized by dataset and DexiNed variant (-a, -f), not application runtime infrastructure.
Paths: utils/image.py, res/BIPED/DexiNed-a/eval_bdry.txt, res/MDBD/DexiNed-f/ios_res.txt
Runtime variants and dependencies
The primary runtime is Python 3.7+ with PyTorch, OpenCV, Matplotlib, Kornia, NumPy, h5py, and PIL. TensorFlow implementations are distinct branches: legacy/ is the historical TF1 implementation, while DexiNed-TF2/ is an incomplete/preliminary TF2 track. Training data and pretrained checkpoints are obtained from external dataset hosts and Google Drive; no service backend is present.
Paths: legacy/train.py, legacy/models/dexined.py, DexiNed-TF2/mainTF.py
Main entry points: datasets.py Tensor loaders · main.py main.py · model.py Side outputs + fusion · image.py Image utilities
Components 16
PyTorch pipeline
Current training and inference implementation.
- main.py · Selects training or inference and controls checkpoint lifecycle.
main.py - Dataset registry · Defines dataset identities and filesystem conventions.
datasets.py - Tensor loaders · Converts images and boundary labels into model-ready tensors.
datasets.py - DexiNed · Dense encoder/decoder edge detector.
model.py - Side outputs + fusion · Produces multi-scale edge maps and a fused prediction.
model.py - BDCN edge loss · Supervises each model output against boundary labels.
losses.py - Image utilities · Prepares and serializes visual edge results.
utils/image.py
Data and artifacts
Repository inputs, lists, and benchmark outputs.
- External checkpoints · Downloaded weights required for checkpoint-based inference.
- BIPED training data · Default training dataset obtained externally.
- MDBD test pairs
dataset-lists/MDBD/test_pair.lst - CLASSIC sample image
data/lena_std.tif - Benchmark results · Stored per dataset and DexiNed variant.
res/BIPED/DexiNed-a/eval_bdry.txt - MDBD evaluation results
res/MDBD/DexiNed-f/ios_res.txt
Alternative runtimes
Separate TensorFlow implementation tracks.
- Legacy TF1 training · Separate historical TensorFlow 1 implementation.
legacy/train.py - Legacy TF1 DexiNed
legacy/models/dexined.py - Preliminary TF2 track · Separate incomplete TensorFlow 2 implementation.
DexiNed-TF2/mainTF.py
Connections 16
- main.py → Dataset registry: selects dataset
- Dataset registry → Tensor loaders: configures
- BIPED training data → Tensor loaders: image/label pairs
- MDBD test pairs → Tensor loaders: test pairs
- CLASSIC sample image → Tensor loaders: sample input
- main.py → Tensor loaders: builds
- main.py → DexiNed: builds
- Tensor loaders → DexiNed: tensors
- DexiNed → Side outputs + fusion: predicts
- main.py → BDCN edge loss: uses for training
- Side outputs + fusion → BDCN edge loss: deep supervision
- main.py → External checkpoints: loads/saves
- Side outputs + fusion → Image utilities: edge maps
- Image utilities → Benchmark results: writes evaluation
- Image utilities → MDBD evaluation results: writes evaluation
- Legacy TF1 training → Legacy TF1 DexiNed: uses