Skip to main content

A Python library for visualizing YOLO detections and segmented instances on large orthomosaic images, with the ability to generate shapefiles for GIS integration

Project description

YOLOmosaic

A Python library for visualizing YOLO detections and segmented instances on large orthomosaic images, with the ability to generate shapefiles for GIS integration

NOTE

This project uses GDAL==3.4.1, to install GDAL on ubuntu. Use the following command:

sudo apt-get install libgdal-dev

Proceed with

pip3 install GDAL==3.4.1

Example usage under CLI mode

ymosaic --input /home/user/Documents/YOLOmosaic/test/images/OUTPUT.tif --type "segment" --model /home/user/Documents/YOLOmosaic/models/best.pt

Expected output:

Input orthomozaic :  OUTPUT.tif
Directory /home/user/Documents/YOLOmosaic/test/images/OUTPUT_output already exists.
Output set to : /home/user/Documents/YOLOmosaic/test/images/OUTPUT_output/OUTPUT.png
segment  model path set to  /home/user/Documents/YOLOmosaic/models/best.pt
Mask type set to  segment
driver_long_name: GeoTIFF
raster_x_size: 3299
raster_y_size: 3693
band_count: 4
projection: PROJCS["WGS 84 / UTM zone 14N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-99],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32614"]]
geotransform: (633491.5605675817, 0.005575933715099989, 0.0, 5193232.824243805, 0.0, -0.005575933715099989)
size: 0.048758922
band_1_metadata: {}
band_2_metadata: {}
band_3_metadata: {}
band_4_metadata: {}
The file {output_png_image} exists.
{GREEN}Conversion successful!{RESET}
starting inference...
Loading model
Checking for CUDA devices
/home/user/.local/lib/python3.10/site-packages/torch/cuda/__init__.py:129: UserWarning: CUDA initialization: CUDA unknown error - this may be due to an incorrectly set up environment, e.g. changing env variable CUDA_VISIBLE_DEVICES after program start. Setting the available devices to be zero. (Triggered internally at ../c10/cuda/CUDAFunctions.cpp:108.)
  return torch._C._cuda_getDeviceCount() > 0
Using device: cpu
Running tiled inference...
Performing prediction on 6 slices.
Time taken to run inference on the orthomozaic: 0.2340 minutes
Detection complete... Saving results
Conveting pixel coordinates to spatial coordinates...
0  polygons could not be processed.
/home/user/.local/lib/python3.10/site-packages/pyogrio/geopandas.py:662: UserWarning: 'crs' was not provided.  The output dataset will not have projection information defined and may not be usable in other systems.
  write(
02/23/2025 01:32:59 - INFO - pyogrio._io -   Created 71 records
Shapefile saved to /home/user/Documents/YOLOmosaic/test/images/OUTPUT_output/OUTPUT.shp

Example usage as python program

from yolomosaic.ymosaic import ortho_inference

input_file = "/home/user/Documents/YOLOmosaic/test/images/OUTPUT.tif"
mask_type = "segment"
model = "/home/user/Documents/YOLOmosaic/models/best.pt"

ortho_inference(input_file, model, mask_type, tile_size=2048, overlap=0.2, conf=0.50)

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

yolomosaic-0.1.2.2.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

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

yolomosaic-0.1.2.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file yolomosaic-0.1.2.2.tar.gz.

File metadata

  • Download URL: yolomosaic-0.1.2.2.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for yolomosaic-0.1.2.2.tar.gz
Algorithm Hash digest
SHA256 a454026e015826f1df0a73b7ba755a98ff7a55e49b5f258b0e245c359c25f5b6
MD5 f5fe15da59bad3312e9b829756769c97
BLAKE2b-256 1ba4592d67d46b814840d4f51103b645f16bb9912ced904794a8e4c4a37df250

See more details on using hashes here.

File details

Details for the file yolomosaic-0.1.2.2-py3-none-any.whl.

File metadata

  • Download URL: yolomosaic-0.1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for yolomosaic-0.1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7e7b9221c1810f5296408d43cd677158e3d1a06e12e21455521754c253302dff
MD5 b2cde66bd648ff5a40fab746906a27cf
BLAKE2b-256 196f0462299099c1bc7c397a09d5e68e6d9790e8fbc4e554c38bc6723e61b107

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