How farizptr/building-detector works
Main Components
• Model Loader & Manager: Represented by functions in modules like detection.py and polygon_detection.py (load_model). This component is responsible for loading the YOLOv8 model (i.e., best.pt).
• Detection Modules:
• Image Detection: Implements detection on single images (detect_buildings, visualize_detections).
• Tile Processing: Processes multiple image tiles in a folder (process_tiles from detection.py).
• Polygon-Based Detection: Handles detection within a GeoJSON polygon (functions in polygon_detection.py).
• GeoJSON & Utility Handlers: Include geojson_utils.py, tile_utils.py, and even building_export.py which may assist in preparing GeoJSON data or visualizing areas.
• Validation & Export Components: Functions in validate.py and building_validation_map.html file suggest checking and exporting validation maps for the building detections.
• Data Storage & Output: Input GeoJSON files (example_area.geojson, padang.geojson, buildings.geojson) and output items like detection_results.json, visualization.png.
Relationships and Interactions
• Data Flow:
• The process begins with the model loader loading the YOLOv8 model.
• The input images (or tiles) and GeoJSON files are fed into the detection pipelines (image, tiles, or polygon-based).
• Results are passed onto the visualization module which creates annotated images, comprehensive maps, and saving detection data (e.g., JSON).
• That both detection modules depend on the model loader.
• That results generated from detection modules are consumed by the visualization components, and optionally, by the validation routines.
• Command-Line Interface (CLI):
• Although not a "component" in the service architecture, include an element representing the CLI commands that trigger these workflows.
Architectural Patterns and Design Principles
• Modular Design: Each .py file encapsulates a specific functionality (detection, visualization, validating, handling geospatial inputs), which is typical in well-separated modular tools.
• Reusability: Utility modules (tile_utils.py and geojson_utils.py) are used across multiple detection modes.
• Pipeline Flow: The data flows from input processing, through detection, to visualization and export.
Final Recommendations
• Notes that showcase design patterns like modular separation and pipeline flow.