Skip to main content

Professional Blender library for synthetic pallet dataset generation.

Project description

PalletDataGenerator

PyPI version Build Status Coverage Status Documentation Status PyPI - Downloads Python 3.11+ Blender 4.5+ License: MIT Code style: black

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_XXXX batch 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:

Warehouse Example 1 Warehouse Example 2

Single Pallet Mode

Generate focused single pallet scenes with detailed box arrangements:

Single Pallet Example 1 Single Pallet Example 2

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

  1. Open the HTML file in any modern web browser
  2. 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
  3. 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

  1. Fork the repository and create a feature branch
  2. Make your changes with proper testing
  3. Run quality checks: black, ruff, mypy, pytest
  4. Update documentation if needed
  5. 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

๐Ÿ™ 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

palletdatagenerator-0.1.3.tar.gz (14.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

palletdatagenerator-0.1.3-py3-none-any.whl (82.1 kB view details)

Uploaded Python 3

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

Hashes for palletdatagenerator-0.1.3.tar.gz
Algorithm Hash digest
SHA256 48a73cb29bea32ada30973302d67adeb45d97dd894a1f692af4d7a03b40ca6a6
MD5 423def9581574b72705d49dbbf11faf4
BLAKE2b-256 73e141df8e1d517192a358db31272fdf86383c8d8a8d806c83a24a99f04584df

See more details on using hashes here.

File details

Details for the file palletdatagenerator-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for palletdatagenerator-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 359f7121f4b1bb20b129cc465bdb0514efffd63bf17d6508791f1d97d94a1323
MD5 096967d896c0834a3d37ccc2fbeec4bd
BLAKE2b-256 fdddc5d1032c4492d15db3c9c7aa674979d7bae74b8ff61b1a063ebd6d17b389

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page