Metadata-Version: 2.4
Name: apb_spatial_computer_vision
Version: 1.1.0
Summary: Python package to integrate image pyramids and raster/vector algorithms for computer vision at Port of Barcelona. Allows text, bounding box and point-based segmentation based on SAMGeo and GroundingDINO. Please refer to the homepage https://victorpachecoaznar.github.io/TFG/
Author-email: Víctor Pacheco Aznar <vpachecoaznar@gmail.com>
License: MIT License
        
        Copyright (c) 2024 VictorPachecoAznar
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: cpu
Requires-Dist: gdal==3.10.2; extra == "cpu"
Requires-Dist: geopandas==1.0.1; extra == "cpu"
Requires-Dist: numpy==2.2.3; extra == "cpu"
Requires-Dist: pandas==2.2.3; extra == "cpu"
Requires-Dist: shapely==2.0.7; extra == "cpu"
Requires-Dist: segment-geospatial==0.12.4; extra == "cpu"
Requires-Dist: duckdb==1.2.0; extra == "cpu"
Requires-Dist: matplotlib==3.10.0; extra == "cpu"
Requires-Dist: pyproj==3.7.1; extra == "cpu"
Requires-Dist: scipy==1.15.2; extra == "cpu"
Requires-Dist: pyarrow==20.0.0; extra == "cpu"
Requires-Dist: openpyxl==3.1.5; extra == "cpu"
Provides-Extra: cuda
Requires-Dist: gdal==3.10.2; extra == "cuda"
Requires-Dist: geopandas==1.0.1; extra == "cuda"
Requires-Dist: numpy==2.2.3; extra == "cuda"
Requires-Dist: pandas==2.2.3; extra == "cuda"
Requires-Dist: shapely==2.0.7; extra == "cuda"
Requires-Dist: segment-geospatial==0.12.4; extra == "cuda"
Requires-Dist: duckdb==1.2.0; extra == "cuda"
Requires-Dist: matplotlib==3.10.0; extra == "cuda"
Requires-Dist: pyproj==3.7.1; extra == "cuda"
Requires-Dist: scipy==1.15.2; extra == "cuda"
Requires-Dist: torch==2.5.1+cu118; extra == "cuda"
Requires-Dist: pyarrow==20.0.0; extra == "cuda"
Requires-Dist: openpyxl==3.1.5; extra == "cuda"
Dynamic: license-file

# TFG
This repository hosts the code for my Bachelors' thesis in Geoinfomation and Geomatics Engineering.
The project has been tutored by Port de Barcelona and Universitat Politècnica de Catalunya.

Please refer to the homepage of the project:

🏡 https://victorpachecoaznar.github.io/TFG/

# About this package
The goal of APB_spatial_computer_vision is to provide a framework to perform computer vision tasks on geospatial imagery.
Its focus is semantic segmentation, mainly though SAM. The logic can be accessed in several points: 

- Through text, to perform image to bbox tasks via Grounding DINO.
- Through bounding box, to perform SAM and achieve segmentation.
- Throgh a lower resolution vector dataset coming from another model, in an attempt to improve segmentation.

# Tools
- 🦆 The program leverages Spatial-SQL **DuckDB** queries for precise vector operations
- ⚡ Image pyramids have been optimized via concurrency to GDAL-warping
- 📷 Integration of virtual layers through GDAL to SAMGeo
- 📄 MKDocs for automated docs+ jupyter visualization

# Instructions
The entry points of the system are the following environment variables:
- TEXT_PROMPT: a string with the prompt to look for via Grounding DINO
- VECTOR_DATASET: a vector dataset
- DATA_DIR: location of the data
- BASE_DIR: where this package is located, acessible for deployments
- NAME_ORTOFOTO: basename for the image to be processed

# Installation
In order to install this package, please download the yaml file in order to create the environment:
- ✅ If CUDA is available:

  ```
  conda env create -f environment_cuda.yaml
  conda activate sam_apb_env
  pip install apb_spatial_computer_vision
  ```
  
- ❌ If CUDA is not available:
  ```
  conda env create -f environment_cpu.yaml
  conda activate sam_apb_env
  pip install apb_spatial_computer_vision
  ```


