Professional Blender library for synthetic pallet dataset generation.
Project description
PalletDataGenerator
A professional Python library for generating high-quality synthetic pallet datasets using Blender for computer vision and machine learning applications.
๐ฏ Overview
PalletDataGenerator is a comprehensive, production-ready solution for creating photorealistic synthetic datasets of pallets and warehouse environments. Designed with professional computer vision workflows in mind, it bridges the gap between research needs and industry-grade dataset generation.
โจ Key Features
- ๐ฌ Dual Generation Modes: Single pallet focus and complex warehouse scenarios
- ๐ Multiple Export Formats: YOLO, COCO JSON, and PASCAL VOC XML annotations
- ๐ฏ Advanced Keypoints Generation: Automatic face detection with 6 keypoints per face, visibility tracking, and 3D debug visualization
- ๐ 3D Debug Visualization: Interactive HTML figures and coordinate tracking for keypoints analysis
- โก GPU-Accelerated Rendering: High-performance generation with Blender Cycles
- ๐ง Flexible Configuration: YAML configs with CLI parameter overrides
- ๐ฆ Professional Output Structure: Organized
generated_XXXXbatch folders with comprehensive metadata - ๐๏ธ Modular Architecture: Clean, extensible, and thoroughly tested codebase
- ๐ Photorealistic Results: Advanced lighting, materials, and post-processing
๐ Quick Start
Prerequisites
- Python 3.11+
- Blender 4.5+ (automatically detected or manually specified)
- NVIDIA GPU (recommended for optimal performance)
Installation
# Install from PyPI (recommended)
pip install palletdatagenerator
# Or install from source for latest features
git clone https://github.com/boubakriibrahim/PalletDataGenerator.git
cd PalletDataGenerator
pip install -e .
Basic Usage
Generate Warehouse Dataset
# Generate 50 warehouse scene images with multiple pallets and boxes
palletgen -m warehouse scenes/warehouse_objects.blend
# Custom configuration
palletgen -m warehouse scenes/warehouse_objects.blend \
--frames 100 \
--resolution 1920 1080 \
--output custom_output_dir
Generate Single Pallet Dataset
# Generate focused single pallet images
palletgen -m single_pallet scenes/one_pallet.blend
# High-resolution batch
palletgen -m single_pallet scenes/one_pallet.blend \
--frames 200 \
--resolution 2048 1536
๐ธ Example Outputs
Warehouse Mode
Generate complex warehouse scenes with multiple pallets, stacked boxes, and realistic lighting:
Single Pallet Mode
Generate focused single pallet scenes with detailed box arrangements:
Multi-Modal Outputs
Each frame generates comprehensive data for training:
| RGB Image | Analysis Overlay | Depth Map | Normal Map |
|---|---|---|---|
๐ฏ Keypoints Generation Examples
Advanced face detection and keypoints tracking with 3D visualization:
| Original Image | Keypoints Analysis | 3D Debug Visualization |
|---|---|---|
Keypoints Features:
- Selective face detection: 1-2 most visible faces per pallet (not all faces)
- 6 keypoints per selected face with precise 2D/3D coordinates
- Visibility tracking using ray casting for occlusion detection
- Interactive 3D HTML figures for detailed analysis
- Comprehensive debug information including face selection criteria
- YOLO format compatibility for seamless integration with training pipelines
๐ 3D Debug Visualization
Advanced debugging tools for keypoints analysis and face detection:
| Interactive 3D Figure | Debug Coordinates | 3D Visualization |
|---|---|---|
| ๐ฏ Open Interactive 3D | ๐ View Coordinates |
Debug Features:
- Interactive 3D visualization with Plotly.js for real-time exploration
- Face selection analysis showing which faces were chosen and why
- Camera positioning with distance calculations to each face
- Pallet corner visualization with camera-to-corner distance lines
- Comprehensive coordinate tracking for debugging and validation
- Note: Keypoints are only visible in 2D analysis images, not in 3D visualization
๐๏ธ Architecture & Features
Generation Modes
๐ญ Warehouse Mode
- Multi-pallet scenes with realistic warehouse layouts
- Dynamic box stacking with collection-aware placement
- Procedural lighting and environment variations
- Complex occlusion scenarios for robust model training
๐ฆ Single Pallet Mode
- Focused pallet detection with controlled backgrounds
- Precise annotation quality for fine-grained training
- Camera angle variations including side and corner views
- Configurable cropping and occlusion levels
๐ฏ Advanced Keypoints Generation
- Automatic face detection by scanning for objects with "face" in their name
- Selective face detection: Detects 1-2 most visible faces from the pallet (not all faces)
- 6 keypoints per selected face: 2 middle (top-down), 2 left (top-down), 2 right (top-down)
- Visibility tracking using ray casting to detect obstacles between face and camera
- YOLO format output with normalized coordinates and visibility flags
- Analysis visualization showing keypoints with different colors for visible/hidden states
- 3D coordinate tracking with detailed debug information for each selected face
- Interactive HTML figures for 3D visualization and analysis
- Comprehensive metadata including face selection criteria and camera positioning
Export Formats
๐ฏ YOLO Format
# Example: 000000.txt
0 0.475345 0.595753 0.247050 0.102537
๐ฏ Keypoints Labels (YOLO Format)
# Example: keypoints_labels/000000.txt
0 0.573150 0.639442 0.284453 0.139362 0.580366 0.603590 2 0.578420 0.669213 2 0.715376 0.569761 2 0.710409 0.633069 2 0.430924 0.641035 2 0.432683 0.709123 2
Format: class_id x_center y_center width height kp1_x kp1_y kp1_v kp2_x kp2_y kp2_v ...
- Visibility:
2=visible,0=hidden - 6 keypoints per face: middle (top/bottom), left (top/bottom), right (top/bottom)
- Real example from generated dataset with actual face detection results
๐ COCO JSON
{
"images": [{"id": 1, "file_name": "000000.png", "width": 1024, "height": 768}],
"annotations": [{"id": 1, "image_id": 1, "category_id": 1, "bbox": [...]}],
"categories": [{"id": 1, "name": "pallet", "supercategory": "object"}]
}
๐ PASCAL VOC XML
<annotation>
<object>
<name>pallet</name>
<bndbox>
<xmin>123</xmin><ymin>456</ymin>
<xmax>789</xmax><ymax>654</ymax>
</bndbox>
</object>
</annotation>
Output Structure
output/
โโโ warehouse/
โ โโโ generated_000001/
โ โ โโโ images/ # RGB images (PNG)
โ โ โโโ analysis/ # Overlay analysis images with keypoints
โ โ โโโ depth/ # Depth maps (PNG)
โ โ โโโ normals/ # Normal maps (PNG)
โ โ โโโ index/ # Index/segmentation maps
โ โ โโโ yolo_labels/ # YOLO format annotations
โ โ โโโ keypoints_labels/ # Keypoints annotations (YOLO format)
โ โ โโโ face_2d_boxes/ # 2D bounding boxes for detected faces
โ โ โโโ face_3d_coordinates/ # 3D coordinates for keypoints
โ โ โโโ debug_3d/ # 3D debug visualization
โ โ โ โโโ coordinates/ # Detailed coordinate information
โ โ โ โโโ figures/ # Interactive HTML 3D figures
โ โ โ โโโ images/ # 3D debug visualization images
โ โ โโโ voc_xml/ # PASCAL VOC annotations
โ โ โโโ coco/ # COCO JSON annotations
โ โโโ generated_000002/ # Next batch...
โโโ single_pallet/
โโโ generated_000001/ # Same structure
๐ Debug 3D Output Details
The debug_3d/ folder contains comprehensive debugging information:
Interactive HTML Figures (figures/)
- Real-time 3D visualization using Plotly.js
- Interactive controls: rotate, zoom, pan, reset view
- Face highlighting: selected faces in red, unselected in blue
- Keypoint visualization: 6 keypoints per selected face
- Camera position: green diamond showing camera location
- Distance calculations: real-time distance from camera to each face
Coordinate Files (coordinates/)
Detailed text files containing:
Frame 0 - 3D Coordinates Debug
Object: pallet
Camera Position: (0.944, 2.536, 1.366)
Selected Faces: face_3, face_1
Pallet Corner Points (8 corners):
Corner 0: (-0.384, -0.600, 0.020) - Distance: 3.663
Corner 1: (-0.384, -0.600, 0.165) - Distance: 3.612
...
All Face Definitions (6 faces total):
face_0 (corners [0, 1, 2, 3]):
Center: (-0.384, 0.000, 0.093) - Distance: 3.134
Status: not selected
face_1 (corners [4, 5, 6, 7]):
Center: (0.400, 0.000, 0.093) - Distance: 2.890
Status: SELECTED
...
Selected Face Details:
face_3 (index 3):
Center Position: (0.008, 0.600, 0.093)
Distance from Camera: 2.499
2D Bounding Box: x_min=441.3, y_min=437.6, x_max=732.5, y_max=544.6
3D Bounding Box: {...}
Debug Images (images/)
- Static 3D visualization for quick reference
- Face selection visualization showing which faces were chosen
- Coordinate system reference for debugging
๐ฎ Using Debug 3D Features
Interactive HTML Visualization
- Open the HTML file in any modern web browser
- Navigate the 3D scene:
- Rotate: Click and drag to rotate the view
- Zoom: Use mouse wheel to zoom in/out
- Pan: Right-click and drag to pan the view
- Reset: Double-click to reset to default view
- Analyze face selection:
- Red circles: Pallet corners (8 corners total)
- Blue diamond: Camera position
- Gray dashed lines: Camera-to-corner distance visualization
- Green/Orange faces: Selected faces for keypoints generation (face_3, face_1)
- Note: Keypoints are only visible in 2D analysis images, not in 3D visualization
Coordinate Analysis
The coordinate files provide detailed information for debugging:
- Face selection criteria: Why certain faces were chosen
- Distance calculations: Camera-to-face distances for selection
- Bounding box data: Both 2D and 3D bounding box information
- Keypoint positions: Exact 3D coordinates of all keypoints
Example Usage
# Generate dataset with debug 3D enabled
palletgen -m single_pallet scenes/one_pallet.blend --frames 10
# View debug files
ls output/single_pallet/generated_XXXXXX/debug_3d/
# coordinates/ figures/ images/
# Open interactive 3D visualization
open output/single_pallet/generated_XXXXXX/debug_3d/figures/frame_000000_3d_interactive.html
# View coordinate details
cat output/single_pallet/generated_XXXXXX/debug_3d/coordinates/frame_000000_coordinates.txt
โ๏ธ Configuration
CLI Parameters
palletgen --help
usage: palletgen [-h] [-m {single_pallet,warehouse}] [-f FRAMES]
[-r WIDTH HEIGHT] [-o OUTPUT] scene_path
Generate synthetic pallet datasets using Blender
positional arguments:
scene_path Path to Blender scene file (.blend)
optional arguments:
-h, --help show this help message and exit
-m, --mode Generation mode: single_pallet or warehouse (default: single_pallet)
-f, --frames Number of frames to generate (default: 50)
-r, --resolution Image resolution as WIDTH HEIGHT (default: 1024 768)
-o, --output Output directory (default: output/{mode}/generated_XXXXXX)
Advanced Configuration
The system supports extensive customization through internal configuration:
# Single Pallet Configuration
SINGLE_PALLET_CONFIG = {
"num_images": 50,
"resolution_x": 1024,
"resolution_y": 768,
"render_engine": "CYCLES",
"camera_focal_mm": 35.0,
"side_face_probability": 0.9,
"allow_cropping": True,
"min_visible_area_ratio": 0.3,
"add_floor": True,
"depth_scale": 1000.0,
# Keypoints Generation Options
"generate_keypoints": True,
"keypoints_min_face_area": 80,
"keypoints_visibility_check": False,
"keypoints_show_3d_labels": False,
"keypoints_show_2d_labels": False,
"analysis_show_keypoints": True,
"analysis_show_2d_boxes": True,
"analysis_show_3d_coordinates": True,
# ... many more options
}
# Warehouse Configuration
WAREHOUSE_CONFIG = {
"num_images": 50,
"resolution_x": 1024,
"resolution_y": 768,
"max_boxes_per_pallet": 8,
"stacking_probability": 0.7,
"lighting_variations": True,
"camera_movement_range": 5.0,
# Keypoints Generation Options (same as single pallet)
"generate_keypoints": True,
"keypoints_min_face_area": 80,
"keypoints_visibility_check": False,
"analysis_show_keypoints": True,
"analysis_show_2d_boxes": True,
"analysis_show_3d_coordinates": True,
# ... extensive warehouse-specific options
}
๐ ๏ธ Development Setup
Development Installation
# Clone and setup development environment
git clone https://github.com/boubakriibrahim/PalletDataGenerator.git
cd PalletDataGenerator
# Install in development mode with all dependencies
pip install -e ".[dev,docs,test]"
# Install pre-commit hooks for code quality
pre-commit install
Code Quality Tools
# Run code formatting
black src/ tests/
# Run linting
ruff check src/ tests/
# Run type checking
mypy src/
# Run all tests with coverage
pytest --cov=palletdatagenerator --cov-report=html
Project Structure
PalletDataGenerator/
โโโ src/palletdatagenerator/
โ โโโ __init__.py
โ โโโ cli.py # Command-line interface
โ โโโ generator.py # Main generator class
โ โโโ config.py # Configuration management
โ โโโ blender_runner.py # Blender execution handler
โ โโโ utils.py # Shared utilities
โ โโโ modes/
โ โโโ base_generator.py # Abstract base class
โ โโโ single_pallet.py # Single pallet mode
โ โโโ warehouse.py # Warehouse mode
โโโ tests/ # Comprehensive test suite
โโโ docs/ # Sphinx documentation
โโโ scenes/ # Example Blender scenes
โโโ original_files/ # Legacy reference implementations
โโโ scripts/ # Development scripts
โโโ readme_images/ # README assets
๐ API Reference
Core Classes
PalletDataGenerator
Main generator class that orchestrates the entire generation process.
from palletdatagenerator import PalletDataGenerator
generator = PalletDataGenerator(
scene_path="scenes/warehouse_objects.blend",
mode="warehouse",
output_dir="custom_output"
)
# Generate dataset
generator.generate_dataset(num_frames=100)
Mode-Specific Generators
from palletdatagenerator.modes import WarehouseMode, SinglePalletMode
# Warehouse mode with custom configuration
warehouse = WarehouseMode(config=custom_warehouse_config)
warehouse.generate_scene(frame_number=0)
# Single pallet mode
single = SinglePalletMode(config=custom_single_config)
single.generate_scene(frame_number=0)
Utility Functions
from palletdatagenerator.utils import (
find_blender_executable,
setup_logging,
validate_scene_file
)
# Auto-detect Blender installation
blender_path = find_blender_executable()
# Validate scene compatibility
is_valid = validate_scene_file("path/to/scene.blend")
๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Workflow
- Fork the repository and create a feature branch
- Make your changes with proper testing
- Run quality checks:
black,ruff,mypy,pytest - Update documentation if needed
- Submit a Pull Request with clear description
๐ License & Citation
License
This project is licensed under the MIT License - see the LICENSE file for details.
Citation
If you use PalletDataGenerator in your research, please cite:
@software{palletdatagenerator2025,
title={PalletDataGenerator: Professional Synthetic Pallet Dataset Generation},
author={Ibrahim Boubakri},
year={2025},
url={https://github.com/boubakriibrahim/PalletDataGenerator},
version={0.1.3}
}
๐ Links & Resources
- ๐ Documentation - Comprehensive guides and API reference
- ๐ Issue Tracker - Report bugs and request features
- ๐ฌ Discussions - Community support and ideas
- ๐ฆ PyPI Package - Latest releases and installation
- ๐ฌ Blender - 3D rendering engine
- ๐ค Computer Vision Datasets - Related projects
๐ Acknowledgments
- Blender Foundation for the incredible open-source 3D suite
- Computer Vision Community for inspiration and feedback
- Contributors who help improve this project
- Warehouse Industry Partners for real-world validation
Made with โค๏ธ for the Computer Vision Community
โญ Star this repo if you find it useful! โญ
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file palletdatagenerator-0.1.3.tar.gz.
File metadata
- Download URL: palletdatagenerator-0.1.3.tar.gz
- Upload date:
- Size: 14.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48a73cb29bea32ada30973302d67adeb45d97dd894a1f692af4d7a03b40ca6a6
|
|
| MD5 |
423def9581574b72705d49dbbf11faf4
|
|
| BLAKE2b-256 |
73e141df8e1d517192a358db31272fdf86383c8d8a8d806c83a24a99f04584df
|
File details
Details for the file palletdatagenerator-0.1.3-py3-none-any.whl.
File metadata
- Download URL: palletdatagenerator-0.1.3-py3-none-any.whl
- Upload date:
- Size: 82.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
359f7121f4b1bb20b129cc465bdb0514efffd63bf17d6508791f1d97d94a1323
|
|
| MD5 |
096967d896c0834a3d37ccc2fbeec4bd
|
|
| BLAKE2b-256 |
fdddc5d1032c4492d15db3c9c7aa674979d7bae74b8ff61b1a063ebd6d17b389
|