Skip to content

Document image dewarping using hybrid 2D-3D approach with geometric refinement

License

Notifications You must be signed in to change notification settings

rtw878/hyb-gridnet

Repository files navigation

Hyb-GridNet: Document Image Dewarping

A research implementation for document image dewarping using a hybrid 2D-3D approach with geometric refinement.

Overview

This project implements a document dewarping system that combines:

  • Dual-stream neural network for initial deformation prediction
  • Axis-alignment refinement for geometric perfection
  • Hybrid approach blending deep learning with traditional optimization

Quick Start

Installation

# Clone the repository
git clone https://github.com/your-username/hyb-gridnet.git
cd hyb-gridnet

# Install dependencies
pip install -r requirements.txt

# Install in development mode
pip install -e .

Basic Usage

import torch
from hyb_gridnet import HybGridNet

# Initialize model
model = HybGridNet(backbone="resnet50", input_size=(512, 512))

# Load and preprocess your image
image = load_image("warped_document.jpg")

# Dewarp the image
dewarped_image, flow_field = model.dewarp(image)

# Save result
save_image(dewarped_image, "rectified_document.jpg")

Architecture

The system consists of two main components:

1. Dual-Stream Network

  • Shared encoder (ResNet/ViT) for feature extraction
  • 3D shape decoder for global geometry understanding
  • 2D flow decoder for local deformation modeling
  • Attention fusion to combine both streams

2. Axis-Alignment Refinement (AARM)

  • Line detection to identify structural features
  • Geometric optimization to enforce axis-alignment
  • Thin-plate splines for smooth interpolation

Project Structure

hyb-gridnet/
├── hyb_gridnet/           # Core package
│   ├── models/           # Neural network architectures
│   ├── modules/          # Core components (AARM, fusion)
│   ├── losses/           # Loss functions
│   ├── data/             # Dataset utilities
│   └── utils/            # Helper functions
├── scripts/              # Training and inference scripts
├── examples/             # Usage examples
└── configs/              # Configuration files

Training

To train the model:

python scripts/train.py --config configs/default.yaml

Status

This is a research implementation. Key features:

  • ✅ Dual-stream network architecture
  • ✅ Axis-alignment refinement module
  • ✅ Basic training pipeline
  • 🔄 Pre-trained models (coming soon)
  • 🔄 Comprehensive evaluation

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

MIT License - see LICENSE for details.

About

Document image dewarping using hybrid 2D-3D approach with geometric refinement

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published