### Getting Started Example Output Source: https://github.com/l1997i/rapid_seg/blob/main/examples/README.md This output shows the successful execution of the basic RAPiD usage demonstration, including point cloud creation, configuration, feature computation, and validation. ```text RAPiD Getting Started Guide ============================================================ ================================================== 1. Basic RAPiD Usage Demonstration ================================================== Creating synthetic point cloud data... Point cloud created: 500 points Coordinates shape: torch.Size([500, 3]) Reflectivity shape: torch.Size([500]) Creating RAPiD configuration... Configuration: RAPiDConfig(...) Initializing RAPiD calculator... Using device: cuda Computing RAPiD features... Using k=8 neighbors RAPiD features computed successfully! Features shape: torch.Size([500, 8]) Features dtype: torch.float32 Features device: cuda:0 Feature statistics: Min value: -0.1234 Max value: 0.5678 Mean value: 0.2345 Std value: 0.3456 Validating features... Features are valid: True [... more output ...] ``` -------------------------------- ### Run Examples with uv Environment Source: https://github.com/l1997i/rapid_seg/blob/main/examples/README.md Activates the virtual environment and runs the getting started example. This is a simplified execution command after setup. ```bash # Activate virtual environment source .venv/bin/activate # Linux/Mac # or .venv\Scripts\activate # Windows # Run examples python examples/01_getting_started.py ``` -------------------------------- ### Run Basic Example Script Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Executes the '01_getting_started.py' example script located in the 'examples' directory. ```bash # Navigate to examples directory cd examples # Run basic example python 01_getting_started.py ``` -------------------------------- ### Development Installation of RAPiD-Seg Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/index.md Guide for installing the library with all development dependencies using pip or uv. ```bash # Clone and install with development dependencies git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg # Install with all development tools pip install -e ".[dev,all]" # Or with uv uv pip install -e ".[dev,all]" ``` -------------------------------- ### Install uv and RAPiD from Source (Recommended) Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Installs the uv package manager and then clones the RAPiD repository, installing it in editable mode using uv. Includes an option to install with development and all dependencies. ```bash # Install uv if not already installed pip install uv # Clone repository git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg # Install with uv (faster and more reliable) uv pip install -e . # Or install with all dependencies uv pip install -e ".[dev,all]" ``` -------------------------------- ### Clone and Setup Development Environment Source: https://github.com/l1997i/rapid_seg/blob/main/README.md Clone the RAPiD-Seg repository and install development dependencies. This includes setting up the project in editable mode and installing pre-commit hooks. ```bash # Clone and setup development environment git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg # Install development dependencies pip install -e ".[dev]" # Run pre-commit hooks pre-commit install # Run tests pytest rapid_seg/tests/ -v ``` -------------------------------- ### Install RAPiD using uv with Virtual Environment Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Installs uv, clones the repository, creates a virtual environment using uv, activates it, and installs RAPiD with development dependencies using uv. ```bash # 1. Install uv (if not already installed) pip install uv # 2. Clone repository git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg # 3. Create virtual environment with uv (recommended) uv venv # 4. Activate virtual environment source .venv/bin/activate # Linux/Mac # or .venv\Scripts\activate # Windows # 5. Install with uv uv pip install -e ".[dev]" ``` -------------------------------- ### Correct RAPiD Installation Method Source: https://github.com/l1997i/rapid_seg/blob/main/QUICKSTART.md Demonstrates the correct method for installing RAPiD from source using uv. Avoid incorrect methods like 'pip install rapid-seg'. ```bash # ❌ These will NOT work: pip install rapid-seg conda install rapid-seg uv pip install rapid-seg # ✅ This IS the correct way: git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg uv pip install -e . ``` -------------------------------- ### Install uv and Clone Repository Source: https://github.com/l1997i/rapid_seg/blob/main/examples/README.md Installs the uv package manager and clones the RAPiD repository. This is a prerequisite for running any examples. ```bash # Install uv (if not already installed) curl -LsSf https://astral.sh/uv/install.sh | sh # Clone repository (REQUIRED - no pip install available) git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg ``` -------------------------------- ### Install RAPiD-Seg from Source Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/index.md Instructions for cloning the repository and installing the library using pip or uv. ```bash # Clone the repository git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg # Install with pip pip install -e . # Or install with uv (faster) uv pip install -e . ``` -------------------------------- ### Install RAPiD using uv Source: https://github.com/l1997i/rapid_seg/blob/main/QUICKSTART.md Install uv, clone the repository, create a virtual environment, and install RAPiD from source using uv pip. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg uv venv source .venv/bin/activate # Linux/Mac # or .venv\Scripts\activate # Windows uv pip install -e . ``` -------------------------------- ### Run Basic RAPiD Examples Source: https://github.com/l1997i/rapid_seg/blob/main/examples/README.md Executes various Python scripts demonstrating different functionalities of RAPiD, including getting started, advanced features, semantic segmentation, memory optimization, performance benchmarking, and integration examples. ```bash # Run getting started example python examples/01_getting_started.py # Run advanced features example python examples/02_advanced_features.py # Run semantic RAPiD example python examples/03_c_rapid_semantic.py # Run memory optimization example python examples/04_memory_optimization.py # Run performance benchmarking python examples/05_performance_benchmarking.py # Run integration examples python examples/06_integration_examples.py ``` -------------------------------- ### Development Installation with Uv Source: https://github.com/l1997i/rapid_seg/blob/main/doc/index.md Install the project with all development and extra dependencies using uv. ```bash uv pip install -e ".[dev,all]" ``` -------------------------------- ### Run Advanced Example Script Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Executes the '02_advanced_features.py' example script located in the 'examples' directory. ```bash # Run comprehensive example python 02_advanced_features.py ``` -------------------------------- ### Correct Installation of Rapid Seg from Source Source: https://github.com/l1997i/rapid_seg/blob/main/examples/README.md Shows the correct method for installing the rapid_seg library from its source repository using git clone and uv pip install. Avoid using pip or conda for installation. ```bash # ❌ This will NOT work: pip install rapid-seg # ✅ This IS the correct way: git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg uv pip install -e . ``` -------------------------------- ### Install with Pip Source: https://github.com/l1997i/rapid_seg/blob/main/doc/index.md Install the project using pip. ```bash pip install -e . ``` -------------------------------- ### Install with Uv Source: https://github.com/l1997i/rapid_seg/blob/main/doc/index.md Install the project using uv for faster dependency management. ```bash uv pip install -e . ``` -------------------------------- ### Install Rapid Seg with All Optional Dependencies Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Installs the library from source, including all available optional dependencies. ```bash cd rapid-seg pip install -e ".[all]" ``` -------------------------------- ### Install RAPiD using pip with Virtual Environment Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Clones the repository, creates a virtual environment, activates it, installs dependencies from requirements.txt, and then installs RAPiD in editable mode with development dependencies. ```bash # 1. Clone repository git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg # 2. Create virtual environment (recommended) python -m venv .venv source .venv/bin/activate # Linux/Mac # or .venv\Scripts\activate # Windows # 3. Install dependencies pip install -r requirements.txt # 4. Install in development mode pip install -e ".[dev]" ``` -------------------------------- ### Create Virtual Environment and Install RAPiD Source: https://github.com/l1997i/rapid_seg/blob/main/examples/README.md Sets up a virtual environment and installs RAPiD from source. Development dependencies can also be included. ```bash # Create and activate virtual environment uv venv source .venv/bin/activate # Linux/Mac # or .venv\Scripts\activate # Windows # Install RAPiD from source (ONLY method available) uv pip install -e . # Or install with development dependencies uv pip install -e ".[dev]" ``` -------------------------------- ### Install RAPiD using pip Source: https://github.com/l1997i/rapid_seg/blob/main/QUICKSTART.md Clone the repository, create a virtual environment, and install RAPiD from source using pip. ```bash git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg python -m venv .venv source .venv/bin/activate # Linux/Mac # or .venv\Scripts\activate # Windows pip install -e . ``` -------------------------------- ### Install RAPiD from Source (Alternative) Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Clones the RAPiD repository and installs it in editable mode using pip. Includes an option to install with development and all dependencies. ```bash # Clone repository git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg # Install in development mode pip install -e . # Or install with all dependencies pip install -e ".[dev,all]" ``` -------------------------------- ### Development Installation with Pip Source: https://github.com/l1997i/rapid_seg/blob/main/doc/index.md Install the project with all development and extra dependencies using pip. ```bash pip install -e ".[dev,all]" ``` -------------------------------- ### Install Rapid Seg with Documentation Dependencies Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Installs the library from source, including tools for generating documentation like sphinx, sphinx-rtd-theme, and myst-parser. ```bash cd rapid-seg pip install -e ".[docs]" ``` -------------------------------- ### Data Loading Examples Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/data.md Examples demonstrating how to load point cloud data using the PointCloudLoader for different formats. ```APIDOC ## Supported Formats ### KITTI Format (.bin) Binary format commonly used in autonomous driving datasets: ```python # Load KITTI data coordinates, reflectivity = loader.load_kitti_format("velodyne/000001.bin") # Data structure: [x, y, z, intensity] # coordinates: (N, 3) - x, y, z coordinates # reflectivity: (N,) - intensity/reflectivity values ``` ### PLY Format (.ply) ASCII/binary format for 3D point clouds: ```python # Load PLY data coordinates, reflectivity = loader.load_and_preprocess("model.ply", "ply") ``` ### PCD Format (.pcd) Point Cloud Data format: ```python # Load PCD data coordinates, reflectivity = loader.load_and_preprocess("cloud.pcd", "pcd") ``` ``` -------------------------------- ### Direct uv Installation of RAPiD Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Clones the RAPiD repository and installs it directly in editable mode using uv. ```bash # Clone and install directly with uv git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg uv pip install -e . ``` -------------------------------- ### Install Rapid Seg with Development Dependencies Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Installs the library from source, including tools for development such as pytest, black, isort, mypy, and jupyter. ```bash cd rapid-seg pip install -e ".[dev]" ``` -------------------------------- ### Direct pip Installation of RAPiD Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Clones the RAPiD repository and installs it directly in editable mode using pip. ```bash # Clone and install directly git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg pip install -e . ``` -------------------------------- ### Install PyTorch with CUDA Support Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Installs PyTorch with CUDA 11.8 support, addressing 'CUDA not available' errors. ```bash # Error: CUDA not available # Solution: Install PyTorch with CUDA support pip install torch --index-url https://download.pytorch.org/whl/cu118 ``` -------------------------------- ### Create Clean Environment and Install Rapid Seg Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Creates a new Python virtual environment, activates it, and installs the Rapid Seg library to resolve version conflicts. ```bash # Error: Version conflicts # Solution: Create clean environment python -m venv clean-env source clean-env/bin/activate cd rapid-seg pip install -e . ``` -------------------------------- ### Performance Benchmarking Example Output Source: https://github.com/l1997i/rapid_seg/blob/main/examples/README.md This output details the system information and performance comparison of different RAPiD configurations, showing computation time and memory usage for various settings. ```text RAPiD Performance Benchmarking and Optimization ====================================================================== System Information ======================================== CPU: 8 cores CPU Frequency: 2400.0 MHz RAM: 16.0 GB GPU: 1 device(s) available GPU 0: NVIDIA GeForce RTX 3080 (10.0 GB) Configuration Performance Comparison ================================================== Testing fast configuration... k=6, Time: 0.0219s ± 0.0009s Memory: 45.23 MB Testing balanced configuration... k=8, Time: 0.0345s ± 0.0012s Memory: 67.89 MB Testing accurate configuration... k=12, Time: 0.0567s ± 0.0018s Memory: 89.45 MB [... more output ...] ``` -------------------------------- ### Verify Rapid Seg Installation and Version Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Tests if the Rapid Seg library can be imported and prints its installed version. Also verifies the successful creation of a RAPiDCalculator instance. ```python # Test import import rapid_seg print(f"RAPiD version: {rapid_seg.__version__}") # Test basic functionality from rapid_seg import RAPiDCalculator calculator = RAPiDCalculator() print("RAPiD calculator created successfully!") ``` -------------------------------- ### Quick Test RAPiD Features Source: https://github.com/l1997i/rapid_seg/blob/main/QUICKSTART.md Initialize RAPiDCalculator and compute features from sample point cloud data. Ensure torch is installed. ```python import torch from rapid_seg import RAPiDCalculator # Create sample point cloud coordinates = torch.randn(100, 3) * 5.0 reflectivity = torch.rand(100) * 0.8 + 0.1 # Initialize calculator calculator = RAPiDCalculator(device="cpu") # Extract features features = calculator.compute_rapid_features(coordinates, reflectivity, k=8) print(f"Features shape: {features.shape}") ``` -------------------------------- ### Setup Logging for Debugging Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Configure logging for RAPiD utilities to capture detailed information during execution. This includes setting the logging level and specifying a log file for debugging purposes. ```python import logging from rapid_seg.utils import setup_logging # Setup logging for debugging setup_logging(level=logging.DEBUG, log_file="rapid_debug.log") # Monitor will now log detailed information monitor = MemoryMonitor() monitor.start_monitoring() ``` -------------------------------- ### Check RAPiD Current Version Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Import the rapid_seg library and print its __version__ attribute to verify the installed version. ```python import rapid_seg print(rapid_seg.__version__) ``` -------------------------------- ### Compute RAPiD Features in Python Source: https://github.com/l1997i/rapid_seg/blob/main/doc/index.md Demonstrates how to compute RAPiD features using sample point cloud data. Ensure you have torch and rapid_seg installed. ```python import torch from rapid_seg import RAPiDCalculator, PointCloudLoader from rapid_seg.config import create_config # Create sample point cloud data n_points = 1000 coordinates = torch.randn(n_points, 3) * 10.0 # 3D coordinates reflectivity = torch.rand(n_points) * 0.8 + 0.1 # Reflectivity values # Initialize RAPiD calculator config = create_config("balanced", k_mid=8) calculator = RAPiDCalculator(device=config.device) # Compute RAPiD features k = config.get_k_for_standard_rapid() rapid_features = calculator.compute_rapid_features( > coordinates, reflectivity, k ) print("RAPiD features shape:", rapid_features.shape) print("Features range: [{:.3f}, {:.3f}]".format(rapid_features.min(), rapid_features.max())) ``` -------------------------------- ### Start and Stop Memory Monitoring Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Use MemoryMonitor to track memory usage during RAPiD computations. Initialize the monitor, start it before computation, and stop it afterward to retrieve statistics. ```python from rapid_seg.utils import MemoryMonitor # Initialize monitor monitor = MemoryMonitor() # Start monitoring monitor.start_monitoring() # Perform RAPiD computation calculator = RAPiDCalculator(device="cuda") features = calculator.compute_rapid_features(coordinates, reflectivity, k=8) # Stop monitoring and get results stats = monitor.stop_monitoring() print(f"Peak memory usage: {stats.peak_memory_mb:.2f} MB") print(f"Average memory usage: {stats.avg_memory_mb:.2f} MB") ``` -------------------------------- ### Get K values for RAPiD Processing Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/config.md Retrieve k values for standard and range-aware RAPiD processing using the configuration object. ```python # Get k value for standard RAPiD k = config.get_k_for_standard_rapid() # Get k values for range-aware processing k_close, k_mid, k_far = config.get_k_for_range_aware_rapid() ``` -------------------------------- ### MemoryMonitor Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Provides real-time memory usage monitoring during RAPiD computation. Users can start, stop, and query memory statistics. ```APIDOC ## MemoryMonitor ### Description Real-time memory usage monitoring during RAPiD computation. ### Methods #### `start_monitoring()` Starts monitoring memory usage. #### `stop_monitoring()` Stops monitoring and returns memory statistics. #### `get_memory_usage()` Returns current memory usage information. ``` -------------------------------- ### Load Data and Compute Standard RAPiD Features Source: https://github.com/l1997i/rapid_seg/blob/main/README.md Loads point cloud data and computes standard RAPiD features using specified parameters. Ensure PyTorch is installed and CUDA is available if using GPU. ```python from rapid_seg import RAPiDCalculator, PointCloudLoader # Load point cloud data loader = PointCloudLoader() coordinates, reflectivity = loader.load_and_preprocess("data.bin") # Create RAPiD calculator calculator = RAPiDCalculator(device="cuda" if torch.cuda.is_available() else "cpu") # Compute standard RAPiD features rapid_features = calculator.compute_rapid_features( coordinates, reflectivity, k=10 ) ``` -------------------------------- ### Monitor RAPiD Computation Metrics Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Use monitor_rapid_computation to get a comprehensive set of metrics during RAPiD feature extraction, including computation time, memory usage, GPU utilization, and throughput. ```python from rapid_seg.utils import monitor_rapid_computation # Monitor computation with detailed metrics metrics = monitor_rapid_computation(calculator, coordinates, reflectivity, k=8) print(f"Computation time: {metrics.computation_time:.3f} seconds") print(f"Memory usage: {metrics.memory_usage_mb:.2f} MB") print(f"GPU utilization: {metrics.gpu_utilization:.1f}%") print(f"Throughput: {metrics.points_per_second:.0f} points/second") ``` -------------------------------- ### setup_logging Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Sets up comprehensive logging for debugging RAPiD computations. ```APIDOC ## setup_logging ### Description Setup logging for debugging. **Parameters:** - `level`: Logging level (e.g., `logging.DEBUG`) - `log_file`: Path to the log file ``` -------------------------------- ### Manage RAPiD Segmentation Configurations Source: https://github.com/l1997i/rapid_seg/blob/main/README.md Demonstrates how to use predefined configurations (balanced, fast, accurate) or create custom configurations with specific parameters like device and batch size. ```python from rapid_seg.config import create_config, RAPiDConfig # Use predefined configurations config = create_config("balanced") # Balanced performance config = create_config("fast") # Fast processing config = create_config("accurate") # High accuracy # Custom configuration custom_config = RAPiDConfig( k_mid=12, device="cuda", batch_size=64 ) ``` -------------------------------- ### Create Predefined RAPiD Configurations Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/config.md Utilize the create_config function to obtain predefined configurations like 'balanced', 'fast', or 'accurate'. ```python from rapid_seg.config import create_config # Balanced configuration (default) balanced_config = create_config("balanced") # Fast processing configuration fast_config = create_config("fast") # High accuracy configuration accurate_config = create_config("accurate") ``` -------------------------------- ### Create Custom RAPiDConfig Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/config.md Instantiate RAPiDConfig with custom parameters for k_mid, device, batch_size, and precision. ```python from rapid_seg.config import RAPiDConfig # Create custom configuration config = RAPiDConfig( k_mid=12, device="cuda", batch_size=64, precision="float32" ) print(f"K neighbors: {config.k_mid}") print(f"Device: {config.device}") ``` -------------------------------- ### Compute RAPiD Features Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/index.md Demonstrates how to compute RAPiD features using sample point cloud data. Ensure RAPiDCalculator and PointCloudLoader are imported. ```python import torch from rapid_seg import RAPiDCalculator, PointCloudLoader from rapid_seg.config import create_config # Create sample point cloud data n_points = 1000 coordinates = torch.randn(n_points, 3) * 10.0 # 3D coordinates reflectivity = torch.rand(n_points) * 0.8 + 0.1 # Reflectivity values # Initialize RAPiD calculator config = create_config("balanced", k_mid=8) calculator = RAPiDCalculator(device=config.device) # Compute RAPiD features k = config.get_k_for_standard_rapid() rapid_features = calculator.compute_rapid_features( coordinates, reflectivity, k ) print("RAPiD features shape:", rapid_features.shape) print("Features range: [{:.3f}, {:.3f}]".format(rapid_features.min(), rapid_features.max())) ``` -------------------------------- ### Create RAPiD Configurations Source: https://github.com/l1997i/rapid_seg/blob/main/QUICKSTART.md Generate configurations for different use cases: fast, balanced, and accurate. These configurations can be used to tune RAPiD's performance and quality. ```python from rapid_seg.config import create_config # Fast configuration for real-time applications fast_config = create_config("fast") # Balanced configuration for general use balanced_config = create_config("balanced") # Accurate configuration for high-quality features accurate_config = create_config("accurate") ``` -------------------------------- ### Preprocessing Options Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/data.md Demonstrates various options available for preprocessing point cloud data. ```APIDOC ## Preprocessing Options ### Normalization ```python # Normalize coordinates to unit sphere options = {"normalize": True, "normalization_type": "sphere"} ``` ### Outlier Removal ```python # Remove statistical outliers options = {"remove_outliers": True, "outlier_threshold": 3.0} ``` ### Downsampling ```python # Voxel-based downsampling options = {"downsample": 0.1, "voxel_size": 0.1} ``` ### Filtering ```python # Range filtering options = { "range_filter": True, "min_range": 0.0, "max_range": 100.0 } ``` ``` -------------------------------- ### Configure Point Cloud Preprocessing Options Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/data.md These snippets show how to configure specific preprocessing options for point cloud data. Combine these options in the `options` dictionary when calling `preprocess_point_cloud`. ```python # Normalize coordinates to unit sphere options = {"normalize": True, "normalization_type": "sphere"} ``` ```python # Remove statistical outliers options = {"remove_outliers": True, "outlier_threshold": 3.0} ``` ```python # Voxel-based downsampling options = {"downsample": 0.1, "voxel_size": 0.1} ``` ```python # Range filtering options = { "range_filter": True, "min_range": 0.0, "max_range": 100.0 } ``` -------------------------------- ### Run All Tests Source: https://github.com/l1997i/rapid_seg/blob/main/README.md Execute all test cases for the RAPiD-Seg project. This command is useful for a comprehensive check of the project's functionality. ```bash # Run all tests pytest rapid_seg/tests/ -v ``` -------------------------------- ### Update RAPiD from Source Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Navigate to the RAPiD source directory, pull the latest changes from the main branch, and reinstall the package in editable mode with upgrades. ```bash cd rapid-seg git pull origin main pip install -e . --upgrade ``` -------------------------------- ### Load and Process Custom Point Cloud Data Source: https://github.com/l1997i/rapid_seg/blob/main/examples/README.md Demonstrates how to load your own point cloud data (coordinates and reflectivity) and process it using the RAPiDCalculator. Ensure your data is converted to PyTorch tensors before processing. ```python # Load your own data from rapid_seg import RAPiDCalculator import numpy as np import torch # Your point cloud data coordinates = np.load("my_coordinates.npy") reflectivity = np.load("my_reflectivity.npy") # Convert to torch tensors coordinates = torch.from_numpy(coordinates).float() reflectivity = torch.from_numpy(reflectivity).float() # Process with RAPiD calculator = RAPiDCalculator(device="cuda") features = calculator.compute_rapid_features(coordinates, reflectivity, k=10) ``` -------------------------------- ### Initialize and Compute C-RAPiD Features Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/variants.md Initializes the C-RAPiD calculator and computes features using coordinates, reflectivity, class labels, and a dictionary specifying k values per class. Ensure 'cuda' is available if 'device="cuda"' is used. ```python from rapid_seg.variants import CRAPiDCalculator # Initialize C-RAPiD calculator c_rapid_calc = CRAPiDCalculator(device="cuda") # Compute C-RAPiD features features = c_rapid_calc.compute_c_rapid_features( coordinates, # (N, 3) - point coordinates reflectivity, # (N,) - reflectivity values class_labels, # (N,) - semantic class labels k_per_class={ 0: 4, 1: 8, 2: 6, 3: 10 } ) ``` -------------------------------- ### Load and Preprocess Point Cloud Data Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/data.md Use this snippet to load point cloud data from a file and apply preprocessing. Specify the format if it's not auto-detectable. ```python from rapid_seg.data import PointCloudLoader # Initialize loader loader = PointCloudLoader() # Load KITTI format data coordinates, reflectivity = loader.load_and_preprocess("data.bin", "kitti") # Apply preprocessing preprocessed_coords, preprocessed_reflectivity = loader.preprocess_point_cloud( coordinates, reflectivity, options={ "normalize": True, "remove_outliers": True, "downsample": 0.1 } ) ``` ```python # Load KITTI data coordinates, reflectivity = loader.load_kitti_format("velodyne/000001.bin") # Data structure: [x, y, z, intensity] # coordinates: (N, 3) - x, y, z coordinates # reflectivity: (N,) - intensity/reflectivity values ``` ```python # Load PLY data coordinates, reflectivity = loader.load_and_preprocess("model.ply", "ply") ``` ```python # Load PCD data coordinates, reflectivity = loader.load_and_preprocess("cloud.pcd", "pcd") ``` -------------------------------- ### Clone Repository Source: https://github.com/l1997i/rapid_seg/blob/main/doc/index.md Clone the RAPiD-Seg repository from GitHub. ```bash git clone https://github.com/l1997i/rapid-seg.git cd rapid-seg ``` -------------------------------- ### RAPiDConfig Device Management Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/config.md Configure the RAPiDConfig to automatically detect the best available device or force a specific one. Includes a check for CUDA availability. ```python # Auto-detect best available device config = RAPiDConfig(device="auto") # Force specific device config = RAPiDConfig(device="cuda:0") # Check device availability if config.is_cuda_available(): print("CUDA is available") ``` -------------------------------- ### Reinstall Rapid Seg to Resolve Import Errors Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Reinstalls the library from source, which can resolve 'No module named 'rapid_seg'' errors. ```bash # Error: No module named 'rapid_seg' # Solution: Ensure proper installation from source cd rapid-seg pip install -e . ``` -------------------------------- ### Log Metrics to TensorBoard Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Integrate with TensorBoard for visualizing RAPiD computation metrics. Use TensorBoardLogger to log memory usage and computation time to a specified directory. ```python from rapid_seg.utils import TensorBoardLogger # Log metrics to TensorBoard logger = TensorBoardLogger(log_dir="./logs") logger.log_memory_usage(peak_memory_mb, avg_memory_mb) logger.log_computation_time(computation_time) ``` -------------------------------- ### Initialize and Compute R-RAPiD Features Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/variants.md Initializes the R-RAPiD calculator and computes features using coordinates with ring information. Ensure coordinates include ring IDs. ```python from rapid_seg.variants import RRAPiDCalculator # Initialize R-RAPiD calculator r_rapid_calc = RRAPiDCalculator(device="cuda") # Compute R-RAPiD features # Note: coordinates should include ring information features = r_rapid_calc.compute_r_rapid_features( coordinates, # (N, 4) - x, y, z, ring_id reflectivity, # (N,) - reflectivity values k_intra_ring=6, # neighbors within same ring k_inter_ring=2 # neighbors from adjacent rings ) ``` -------------------------------- ### Select Optimal Computation Device Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Automatically select the best available device (e.g., CUDA or CPU) for RAPiD computation based on user preference, fallback options, and estimated memory requirements. ```python from rapid_seg.utils import select_optimal_device # Automatically select best available device device = select_optimal_device( preferred_device="cuda", fallback_device="cpu", memory_requirement_mb=4000 ) print(f"Selected device: {device}") ``` -------------------------------- ### Compute R-RAPiD Features with Sample Data Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/variants.md Demonstrates computing R-RAPiD features using PyTorch tensors for coordinates, ring IDs, and reflectivity. The coordinates tensor must be augmented with a ring ID column. ```python import torch from rapid_seg.variants import RRAPiDCalculator # Create sample data with ring information n_points = 1000 coordinates = torch.randn(n_points, 3) * 10.0 ring_ids = torch.randint(0, 64, (n_points,)) # 64-ring LiDAR reflectivity = torch.rand(n_points) * 0.8 + 0.1 # Combine coordinates and ring IDs coordinates_with_rings = torch.cat([coordinates, ring_ids.unsqueeze(1)], dim=1) # Initialize R-RAPiD calculator r_rapid_calc = RRAPiDCalculator(device="cuda") # Compute features features = r_rapid_calc.compute_r_rapid_features( coordinates_with_rings, reflectivity, k_intra_ring=8, k_inter_ring=3 ) print(f"R-RAPiD features shape: {features.shape}") ``` -------------------------------- ### Run Tests with Coverage Source: https://github.com/l1997i/rapid_seg/blob/main/README.md Execute all test cases and generate an HTML report for code coverage. This helps in identifying areas of the code that are not adequately tested. ```bash # Run with coverage pytest rapid_seg/tests/ --cov=rapid_seg --cov-report=html ``` -------------------------------- ### select_optimal_device Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Automatically selects the best available device (e.g., CUDA or CPU) for computation, considering preferences and memory requirements. ```APIDOC ## select_optimal_device ### Description Automatically select best available device. **Parameters:** - `preferred_device`: Preferred device (e.g., "cuda") - `fallback_device`: Fallback device (e.g., "cpu") - `memory_requirement_mb`: Required memory in MB **Returns:** - Selected device ``` -------------------------------- ### Optimize Batch Size for Memory Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Determine the optimal batch size for RAPiD computation given the number of points, k-neighbors, available memory, and data precision. This utility helps in maximizing performance within memory constraints. ```python from rapid_seg.utils import optimize_batch_size # Find optimal batch size for available memory optimal_batch_size = optimize_batch_size( n_points=50000, k=8, available_memory_mb=8000, precision="float32" ) print(f"Optimal batch size: {optimal_batch_size}") ``` -------------------------------- ### Compute RAPiD Features Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/core.md Computes standard RAPiD features from point cloud coordinates and reflectivity. Requires initialization of RAPiDCalculator. ```python from rapid_seg.core import RAPiDCalculator import torch # Initialize calculator calculator = RAPiDCalculator(device="cuda") # Sample data coordinates = torch.randn(1000, 3) reflectivity = torch.rand(1000) # Standard RAPiD features = calculator.compute_rapid_features(coordinates, reflectivity, k=8) ``` -------------------------------- ### Initialize and Compute Hybrid Features Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/variants.md Initializes the HybridRAPiDCalculator and computes hybrid features using specified variant weights. Ensure the 'cuda' device is available if specified. ```python from rapid_seg.variants import HybridRAPiDCalculator # Initialize hybrid calculator hybrid_calc = HybridRAPiDCalculator(device="cuda") # Compute hybrid features features = hybrid_calc.compute_hybrid_features( coordinates, reflectivity, ring_ids, # for R-RAPiD class_labels, # for C-RAPiD variant_weights={ "standard": 0.3, "r_rapid": 0.4, "c_rapid": 0.3 } ) ``` -------------------------------- ### Run Specific Test Categories Source: https://github.com/l1997i/rapid_seg/blob/main/README.md Execute test cases for specific modules within the RAPiD-Seg project. Use this to focus testing on particular components like 'core' or 'features'. ```bash # Run specific test categories pytest rapid_seg/tests/test_core.py -v pytest rapid_seg/tests/test_features.py -v ``` -------------------------------- ### Map Reflectivity Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/core.md Maps raw reflectivity values using specified strategies like 'linear', 'log', or 'normalized'. Requires initialization of ReflectivityMapper. ```python from rapid_seg.core import ReflectivityMapper mapper = ReflectivityMapper() mapped_reflectivity = mapper.map_reflectivity(reflectivity, "log") ``` -------------------------------- ### Force CPU Usage to Resolve Memory Issues Source: https://github.com/l1997i/rapid_seg/blob/main/INSTALL.md Sets the device to 'cpu' to mitigate 'CUDA out of memory' errors by preventing GPU usage. ```python # Error: CUDA out of memory # Solution: Reduce batch size or use CPU device = "cpu" # Force CPU usage ``` -------------------------------- ### TensorBoardLogger Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Integrates with TensorBoard for logging performance metrics such as memory usage and computation time. ```APIDOC ## TensorBoardLogger ### Description Log metrics to TensorBoard. **Parameters:** - `log_dir`: Directory to save TensorBoard logs ### Methods #### `log_memory_usage(peak_memory_mb, avg_memory_mb)` Logs peak and average memory usage. #### `log_computation_time(computation_time)` Logs computation time. ``` -------------------------------- ### estimate_memory_requirements Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Estimates the memory requirements for RAPiD computation based on input parameters. ```APIDOC ## estimate_memory_requirements ### Description Estimates memory requirements for RAPiD computation. **Parameters:** - `n_points`: Number of points in the point cloud - `k`: Number of nearest neighbors - `batch_size`: Processing batch size - `precision`: Data precision **Returns:** - Estimated memory requirements in MB ``` -------------------------------- ### Compute C-RAPiD Features with Class-Specific Configuration Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/variants.md Computes C-RAPiD features using a dictionary that defines class-specific parameters like 'k' and 'batch_size' for each semantic class. This allows for fine-tuned feature extraction based on class complexity. ```python # Define class-specific parameters class_config = { 0: {"k": 4, "batch_size": 64}, # road - simple geometry 1: {"k": 8, "batch_size": 32}, # car - medium complexity 2: {"k": 6, "batch_size": 48}, # pedestrian - simple 3: {"k": 12, "batch_size": 16}, # building - complex geometry 4: {"k": 5, "batch_size": 56} # vegetation - medium } # Compute features with class-specific settings features = c_rapid_calc.compute_c_rapid_features( coordinates, reflectivity, class_labels, class_config ) ``` -------------------------------- ### PointCloudLoader Class Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/data.md The PointCloudLoader class is the main interface for loading and preprocessing point cloud data from different file formats. ```APIDOC ## PointCloudLoader Main class for loading and preprocessing point cloud data from various formats. ### Methods #### `load_and_preprocess(file_path, format="auto")` Loads point cloud data and applies preprocessing steps. **Parameters:** - `file_path`: Path to the point cloud file - `format`: File format (“auto”, “kitti”, “ply”, “pcd”) **Returns:** - `coordinates`: Point coordinates (N, 3) - `reflectivity`: Reflectivity values (N,) #### `load_kitti_format(file_path)` Loads point cloud data in KITTI format (.bin files). **Parameters:** - `file_path`: Path to KITTI .bin file **Returns:** - `coordinates`: Point coordinates (N, 3) - `reflectivity`: Reflectivity values (N,) #### `preprocess_point_cloud(coordinates, reflectivity, options=None)` Applies preprocessing operations to loaded point cloud data. **Parameters:** - `coordinates`: Raw point coordinates - `reflectivity`: Raw reflectivity values - `options`: Preprocessing options dictionary **Returns:** - Preprocessed coordinates and reflectivity #### `validate_point_cloud(coordinates, reflectivity)` Validates the integrity of the point cloud data. **Parameters:** - `coordinates`: Point coordinates - `reflectivity`: Reflectivity values **Returns:** - `is_valid`: Boolean indicating if the data is valid. ``` -------------------------------- ### Optimize Batch Size Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/config.md Adjust the batch size dynamically based on available memory using the optimize_batch_size method. ```python # Adjust batch size based on available memory config.optimize_batch_size(available_memory_gb=8.0) ``` -------------------------------- ### Estimate RAPiD Memory Requirements Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Calculate the estimated memory needed for RAPiD computation based on the number of points, k-neighbors, batch size, and data precision. This is useful for pre-allocating resources or adjusting parameters. ```python from rapid_seg.utils import estimate_memory_requirements # Estimate memory for large point cloud memory_mb = estimate_memory_requirements( n_points=100000, k=8, batch_size=32, precision="float32" ) print(f"Estimated memory requirement: {memory_mb:.2f} MB") # Check if system has enough memory if memory_mb > available_memory_mb: print("Warning: Insufficient memory available") # Adjust batch size or k value ``` -------------------------------- ### Compute Range-Aware RAPiD Features Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/core.md Computes range-aware RAPiD features using different neighbor counts for varying point cloud ranges. Requires initialization of RAPiDCalculator. ```python from rapid_seg.core import RAPiDCalculator import torch # Initialize calculator calculator = RAPiDCalculator(device="cuda") # Sample data coordinates = torch.randn(1000, 3) reflectivity = torch.rand(1000) # Range-aware RAPiD range_features = calculator.compute_range_aware_rapid( coordinates, reflectivity, k_close=3, k_mid=8, k_far=2 ) ``` -------------------------------- ### Export Performance Metrics to CSV Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Save performance metrics from RAPiD computations to a CSV file for further analysis or reporting. This function takes a list of metrics and an output file path. ```python from rapid_seg.utils import export_metrics_to_csv # Export performance metrics export_metrics_to_csv( metrics_list, output_file="rapid_performance.csv" ) ``` -------------------------------- ### Sort Points Lexicographically Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/core.md Sorts point cloud coordinates using lexicographical ordering for consistent processing. Requires initialization of SortingModule. ```python from rapid_seg.core import SortingModule sorter = SortingModule() sorted_coords, indices = sorter.sort_points_lexicographically(coordinates) ``` -------------------------------- ### MemoryProfiler Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Offers detailed memory profiling with allocation tracking for specific functions. ```APIDOC ## MemoryProfiler ### Description Detailed memory profiling with allocation tracking. ### Methods #### `profile_function(func, *args, **kwargs)` Profiles memory usage of a specific function. **Parameters:** - `func`: Function to profile - `*args, **kwargs`: Function arguments **Returns:** - Memory profile results #### `get_memory_breakdown()` Returns detailed memory usage breakdown by component. ``` -------------------------------- ### monitor_rapid_computation Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Monitors RAPiD computation, providing comprehensive metrics including computation time, memory usage, GPU utilization, and throughput. ```APIDOC ## monitor_rapid_computation ### Description Monitors RAPiD computation with comprehensive metrics. **Parameters:** - `calculator`: RAPiDCalculator instance - `coordinates`: Point cloud coordinates - `reflectivity`: Reflectivity values - `k`: Number of neighbors **Returns:** - Computation metrics and memory usage ``` -------------------------------- ### optimize_batch_size Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Optimizes the batch size for RAPiD computation based on specified parameters and available memory. ```APIDOC ## optimize_batch_size ### Description Find optimal batch size for available memory. **Parameters:** - `n_points`: Number of points in the point cloud - `k`: Number of nearest neighbors - `available_memory_mb`: Available memory in MB - `precision`: Data precision **Returns:** - Optimal batch size ``` -------------------------------- ### SortingModule.sort_points_lexicographically Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/core.md Provides lexicographic sorting utilities for point cloud processing, ensuring consistent ordering. ```APIDOC ## sort_points_lexicographically(coordinates) ### Description Sorts points using lexicographic ordering for consistent processing. ### Parameters - **coordinates** (tensor) - Point coordinates (N, 3) ### Returns - Sorted coordinates - Sorting indices ``` -------------------------------- ### Compute 4D Distances Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/core.md Computes 4D distances combining geometric and reflectivity components for point clouds. Requires initialization of DistanceCalculator. ```python from rapid_seg.core import DistanceCalculator calculator = DistanceCalculator(device="cuda") distances, indices = calculator.compute_4d_distances(coordinates, reflectivity, k=8) ``` -------------------------------- ### export_metrics_to_csv Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Exports performance metrics to a CSV file. ```APIDOC ## export_metrics_to_csv ### Description Export performance metrics. **Parameters:** - `metrics_list`: A list of metrics to export - `output_file`: The path to the output CSV file ``` -------------------------------- ### Profile Function Memory Usage Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/utils.md Employ MemoryProfiler to track memory allocation and deallocation for specific functions. This helps in identifying memory-intensive parts of your computation. ```python from rapid_seg.utils import MemoryProfiler profiler = MemoryProfiler() # Profile RAPiD computation def compute_features(): return calculator.compute_rapid_features(coordinates, reflectivity, k=8) results = profiler.profile_function(compute_features) print(f"Memory allocated: {results.total_allocated_mb:.2f} MB") print(f"Memory freed: {results.total_freed_mb:.2f} MB") ``` -------------------------------- ### Define a Custom RAPiD Variant Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/variants.md Extend the base RAPiDCalculator class to introduce custom parameters and computation methods. This is useful for adding specialized logic to the variant. ```python from rapid_seg.core import RAPiDCalculator class CustomRAPiDCalculator(RAPiDCalculator): def __init__(self, custom_param, **kwargs): super().__init__(**kwargs) self.custom_param = custom_param def compute_custom_features(self, coordinates, reflectivity): # Custom feature computation logic pass ``` -------------------------------- ### RAPiDCalculator.compute_range_aware_rapid Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/core.md Computes range-aware RAPiD features by applying different numbers of nearest neighbors for different distance ranges. ```APIDOC ## compute_range_aware_rapid(coordinates, reflectivity, k_close, k_mid, k_far) ### Description Computes range-aware RAPiD features with different k values for different ranges. ### Parameters - **coordinates** (tensor) - Point cloud coordinates (N, 3) - **reflectivity** (tensor) - Reflectivity values (N,) - **k_close** (int) - Neighbors for close range points - **k_mid** (int) - Neighbors for mid range points - **k_far** (int) - Neighbors for far range points ### Returns - Range-aware RAPiD features tensor (N, feature_dim) ``` -------------------------------- ### Validate Point Cloud Data Integrity Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/data.md Use this method to check if the loaded point cloud data is valid before further processing. Handle invalid data appropriately. ```python # Validate data integrity is_valid = loader.validate_point_cloud(coordinates, reflectivity) if not is_valid: print("Invalid point cloud data detected") # Handle invalid data ``` -------------------------------- ### ReflectivityMapper.map_reflectivity Source: https://github.com/l1997i/rapid_seg/blob/main/doc/source/core.md Maps raw reflectivity values to appropriate feature representations using specified mapping strategies. ```APIDOC ## map_reflectivity(reflectivity, mapping_type="linear") ### Description Maps raw reflectivity values using different strategies. ### Parameters - **reflectivity** (tensor) - Raw reflectivity values - **mapping_type** (str) - Mapping strategy (“linear”, “log”, “normalized”) ### Returns - Mapped reflectivity features ```