Enhanced version of the Im2Height model with support for multiple datasets, improved GPU handling, and comprehensive workflow management.
Training and prediction ONLY work with NPY format files. If your dataset contains raw images, you MUST run preprocessing first to convert them to NPY format.
- Check dataset →
./run.sh --action info --dataset /path/to/dataset - Preprocess →
./run.sh --action preprocess --dataset /path/to/dataset(if needed) - Train →
./run.sh --action train --dataset /path/to/dataset - Predict →
./run.sh --action predict --dataset /path/to/dataset
# Run everything automatically
./run.sh --action all --dataset /path/to/your/dataset --gpus 0,1dataset/
├── train/
│ ├── x/ # Input images as .npy files
│ └── y/ # Target height maps as .npy files
├── test/
│ ├── x/ # Test input images as .npy files
│ └── y/ # Test target height maps as .npy files
└── valid/ # Optional validation split
├── x/
└── y/
dataset/
├── train/
│ ├── rgb/ # RGB images (.jpg, .png, .tif)
│ └── dsm/ # Height maps (.tif, .npy)
├── test/
│ ├── rgb/
│ └── dsm/
└── valid/
├── rgb/
└── dsm/
- Clone and setup:
git clone <your-repo>
cd IM2HEIGHT
pip install -r requirements.txt- Make scripts executable:
chmod +x run.sh./run.sh --action info --dataset /path/to/datasetThis will show:
- Dataset format (NPY or image)
- Split information (train/test/valid)
- File counts and structure
# Convert image dataset to NPY format
./run.sh --action preprocess --dataset /path/to/image_dataset
# Force reprocessing even if NPY files exist
./run.sh --action preprocess --dataset /path/to/dataset --force# Basic training
./run.sh --action train --dataset /path/to/npy_dataset
# Training with specific GPU configuration
./run.sh --action train --dataset /path/to/dataset --gpus 0,1
# Training with custom parameters
./run.sh --action train --dataset /path/to/dataset \
--patience 50 --epochs 500 --gpus 0# Prediction with automatic weight detection
./run.sh --action predict --dataset /path/to/dataset
# Prediction with specific weights
./run.sh --action predict --dataset /path/to/dataset \
--weights weights/model_best.ckpt --output custom_predictions/# Run preprocess + train + predict automatically
./run.sh --action all --dataset /path/to/dataset --gpus 0,1- DFC2023mini: Street View imagery dataset
- DFC2023S: Satellite imagery dataset
- Custom datasets: Any image format with corresponding height maps
- Legacy NPY: Original Im2Height format
- Multi-GPU training with automatic configuration
- Memory optimization and CUDA cache management
- Dynamic GPU selection via command line
- Memory-efficient loading with lazy evaluation
- Automatic format detection for input datasets
- Efficient NPY conversion with caching
- Multiple image formats (.jpg, .png, .tif, .tiff)
- Progress tracking and error handling
- Early stopping with configurable patience
- Model checkpointing with best model selection
- Learning rate scheduling and optimization
- Validation monitoring and logging
Usage: ./run.sh [OPTIONS]
Actions:
info Display dataset information and format
preprocess Convert images to NPY format
train Train the model (requires NPY format)
predict Run predictions (requires NPY format)
all Run complete pipeline
Options:
-d, --dataset PATH Path to dataset
-g, --gpus GPUs GPU indices to use (e.g. '0,1')
-p, --patience NUMBER Early stopping patience (default: 200)
-e, --epochs NUMBER Maximum training epochs (default: 1000)
-w, --weights PATH Path to model weights (for prediction)
-o, --output DIR Output directory (for prediction)
--force Force reprocess even if NPY files exist
--quiet Suppress verbose outputBased on the original Im2Height paper (arXiv:1802.10249):
- Fully residual convolutional-deconvolutional network
- Skip connections for preserving fine details and boundaries
- End-to-end training without post-processing
- RGB to DSM conversion specialized for height estimation
"ERROR: Image format dataset detected"
# Solution: Run preprocessing first
./run.sh --action preprocess --dataset /path/to/datasetGPU memory errors during training
# Solution: Use fewer GPUs or reduce batch size
./run.sh --action train --dataset /path/to/dataset --gpus 0No model weights found for prediction
# Solution: Train a model first or specify weights path
./run.sh --action train --dataset /path/to/dataset
# Then predict:
./run.sh --action predict --dataset /path/to/datasetIM2HEIGHT/
├── run.sh # Main workflow script
├── data.py # Enhanced dataset handling (NPY-only)
├── preprocess.py # Multi-dataset preprocessing
├── train.py # Enhanced training script
├── predict.py # Prediction script
├── im2height.py # Enhanced model implementation
├── augmenter.py # Data augmentation
├── requirements.txt # Dependencies
├── data/ # Processed datasets (NPY format)
├── weights/ # Trained model weights
├── predictions/ # Prediction outputs
└── tools/ # Visualization and metrics tools
├── read_pdf.py # PDF text extraction utility
├── metrics.py # Performance evaluation metrics
└── visualize_results_*.ipynb # Result visualization notebooks
If you use this enhanced version, please cite both the original paper and acknowledge the enhancements:
@article{mou2018im2height,
title={IM2HEIGHT: Height Estimation from Single Monocular Imagery via Fully Residual Convolutional-Deconvolutional Network},
author={Mou, Lichao and Zhu, Xiao Xiang},
journal={arXiv preprint arXiv:1802.10249},
year={2018}
}This enhanced version includes:
- Multi-dataset support and preprocessing pipeline
- Improved GPU handling and memory management
- Comprehensive workflow management with comprehensive error handling
- Enhanced documentation and user experience
This project maintains compatibility with the original Im2Height implementation while adding significant enhancements for production use and research applications.