Buckets:
| #!/usr/bin/env python3 | |
| """ | |
| Usage example for unified_tiff_to_512png.py | |
| This script demonstrates how to use the XBDConverter class to convert | |
| xBD TIFF files to 512x512 PNG files with different configurations. | |
| """ | |
| from unified_tiff_to_512png import XBDConverter | |
| def example_basic_usage(): | |
| """ | |
| Basic usage example - converts all TIFF files to 512x512 PNG | |
| """ | |
| print("=== Basic Usage Example ===") | |
| # Create converter with default settings | |
| converter = XBDConverter() | |
| # Run the full conversion pipeline | |
| converter.run_full_conversion(crop_size=512) | |
| print("Conversion completed!") | |
| def example_custom_paths(): | |
| """ | |
| Example with custom input and output directories | |
| """ | |
| print("=== Custom Paths Example ===") | |
| # Custom input and output directories | |
| input_dir = "/path/to/your/xview2_geotiff/geotiffs" | |
| output_dir = "/path/to/your/output/images-w512-h512" | |
| converter = XBDConverter(input_dir=input_dir, output_dir=output_dir) | |
| converter.run_full_conversion(crop_size=512) | |
| print("Custom path conversion completed!") | |
| def example_different_crop_sizes(): | |
| """ | |
| Example showing how to create different crop sizes | |
| """ | |
| print("=== Different Crop Sizes Example ===") | |
| converter = XBDConverter() | |
| # Create 256x256 images | |
| converter.run_full_conversion(crop_size=256) | |
| print("256x256 conversion completed!") | |
| # Create 128x128 images | |
| converter.run_full_conversion(crop_size=128) | |
| print("128x128 conversion completed!") | |
| def example_step_by_step(): | |
| """ | |
| Example showing how to run each step individually | |
| """ | |
| print("=== Step-by-Step Example ===") | |
| converter = XBDConverter() | |
| # Step 1: Restructure dataset | |
| print("Step 1: Restructuring dataset...") | |
| converter.restructure_dataset() | |
| # Step 2: Convert TIFF to PNG | |
| print("Step 2: Converting TIFF to PNG...") | |
| converter.convert_all_tif_to_png() | |
| # Step 3: Crop images | |
| print("Step 3: Cropping images...") | |
| converter.crop_all_images(crop_size=512) | |
| # Step 4: Organize pre/post images | |
| print("Step 4: Organizing pre/post images...") | |
| converter.organize_pre_post_images() | |
| print("Step-by-step conversion completed!") | |
| if __name__ == "__main__": | |
| print("xBD TIFF to 512x512 PNG Converter - Usage Examples") | |
| print("=" * 50) | |
| # Uncomment the example you want to run: | |
| # example_basic_usage() | |
| # example_custom_paths() | |
| # example_different_crop_sizes() | |
| # example_step_by_step() | |
| print("\nTo run an example, uncomment the desired function call above.") | |
| print("Make sure to adjust paths according to your setup.") | |
Xet Storage Details
- Size:
- 2.7 kB
- Xet hash:
- e31c4e39c7133a57283e1a98347dc83b1145fe5ca3928e5671fcbcf15d95c8b0
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.