Coder Social home page Coder Social logo

orthoseg / orthoseg Goto Github PK

View Code? Open in Web Editor NEW
21.0 4.0 4.0 4.37 MB

OrthoSeg makes it easy to train neural networks to segment orthophotos.

License: GNU General Public License v3.0

Python 100.00%
image-segmentation segment-orthophotos segmentation keras-tensorflow aerial-imagery satellite-imagery drone neural-network python wms

orthoseg's Introduction

Orthophoto segmentation

Actions Status PyPI version DOI

This project provides a procedure and software to make it easy to:

  1. create a training dataset for a topic of your choice
  2. train a neural network to segment orthophotos
  3. run the segmentation on a larger area + vectorize the result
  4. apply some basic postprocessing like dissolve,...

Only open source software is needed, eg. QGIS and tensorflow.

Installation and usage instructions can be found in the orthoseg wiki

orthoseg's People

Contributors

dependabot[bot] avatar theroggy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

orthoseg's Issues

Add option to use topologic simplify

For multi-class predictions, often there different detected classes are located next to each other in the result. When simplification is applied to each resulting polygon separately, the result of the simplification will often result in gaps between both polygon borders.

If, prior to the simplification, the polygons would be converted to topologies, the simplification on the common line of the two polygons would only be applied once and hence will result in a border without gaps, even if the topologies are afterwards saved as seperate polygons again.

Improve/add options to monitor training progress

  • add support for one hot IOU + make default
  • it is already possible to configure which (combination of) metrics is used to monitor training progress/selection of best model, but it is always a combination of training metrix and validation metrics. Make this configurable as well.

ENH: add feature to reclassify (small) features to the class of its neighbour

Configurable via the following parameter:

[predict]

# Reclassify all detected polygons that comply to the query provided to the class of
# the neighbour with the longest border with it.
# The query need to be in the form to be used by pandas.DataFrame.query() and the
# following columns are available to query on:
#   - area: the area of the polygon, as calculated by GeoSeries.area
#   - perimeter: the perimeter of the polygon, as calculated by GeoSeries.length
# Eg.: reclassify_to_neighbour_query = area <= 5
reclassify_to_neighbour_query

Change default columns name for class in label_polygons to classname

The default column name for the class in a training data input file is "label_name", but in the predicted output the column is called "classname". Because of this, the class name is lost when copying rows from the prediction to the polygons label file which is impractical.

So, the default name in labelpolygons.gpkg should be classname as well, but label_name should stay supported as well for backwards compatibility

BUG: train gives an error after training if there are no "test" locations defined

Not blocking, but obviously cleaner if this doesn't give an error.

Error:

Exception: Found no ['.png', '.tif', '.jpg'] images to predict in X:\Monitoring\OrthoSeg\animals\training\01\test\image

Traceback (most recent call last): File "C:\Tools\mambaforge\envs\orthoseg\lib\site-packages\orthoseg\train.py", line 437, in train predicter.predict_dir( File "C:\Tools\mambaforge\envs\orthoseg\lib\site-packages\orthoseg\lib\predicter.py", line 156, in predict_dir raise ValueError(f"Found no {input_ext} images to predict in {input_image_dir}") ValueError: Found no ['.png', '.tif', '.jpg'] images to predict in X:\Monitoring\OrthoSeg\animals\training\01\test\image 

Add option to limit CPU usage while predicting

Since version 0.3 it's possible to limit the amount of parallelisation used in postprocessing, but in some cases the CPU usage while predicting can become very high (up to 100%) as well.

Making the nb_parallel parameter general instead of specific for postprocessing seems the cleanest solution.

Errors when predicting with topologic simplify

For some predicted tiles an error is thrown in the inline-post processing during the prediction.

These are the errors that seem to occur:

  • File "C:\Users\pierog\projects_github\orthoseg\orthoseg\util\vector_util.py", line 151, in simplify_topolines       
        topoline_simpl = topolines_simpl.geoms[index].coords  # type: ignore
    AttributeError: 'LineString' object has no attribute 'geoms'
    
  • fiona.errors.GeometryTypeValidationError: Record's geometry type does not match collection 
        schema's geometry type: 'LineString' != 'Polygon'
    
  • File "C:\Users\pierog\projects_github\orthoseg\orthoseg\util\vector_util.py", line 183, in simplify_topo_orthoseg        
              topolines_simplified = simplify_topolines(
         File "C:\Users\pierog\projects_github\orthoseg\orthoseg\util\vector_util.py", line 147, in simplify_topolines
              assert topolines_simpl is not None
    

Add traindata type todo

Now there are label types train, validation and test. A type todo would be practical to signify label locations that still need to be digitized.

Creation of spatial indexes on the output geopackage files fails on Windows

Wherever geopackage files are created in orthoseg on Windows, rtree creation errors are shown and the spatial index is not created.

This is a known issue. Probably there is an incompatibility between packages installed that results in a wrong version of sqlite being used... without support for rtree indexes.

As of now there is no known solution :-(.

Prediction throws error on Ubuntu 22.04

Hi all,

So I created the conda environment for orthoseg (resulting environment attached). I have followed the wiki entry and all is fine until I try to predict.

When I try to predict I get the following error (on Ubuntu 22.04 LTS).

$ orthoseg_predict --config ./work/arpa/orthoseg/sample_projects/orthoseg/sample_projects/footballfields/footballfields.ini 
2022-11-29 16:13:46.859616: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2022-11-29 16:13:46.859638: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Segmentation Models: using keras framework.
16:13:48.804|INFO|root|Start predict for config footballfields
16:13:48.807|INFO|root|Best model found: /home/jp/work/arpa/orthoseg/sample_projects/orthoseg/sample_projects/footballfields/models/footballfields_01_0.92512_242.hdf5
16:13:48.807|INFO|root|Tensorrt is available, so use optimized model
16:13:48.807|ERROR|root|ERROR while running predict for task footballfields
Traceback (most recent call last):
  File "/opt/miniconda3/envs/orthoseg/lib/python3.9/site-packages/orthoseg/predict.py", line 166, in predict
    best_model["filepath"].parent / best_model["filepath"].stem + "_optim"
TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'
16:13:48.808|ERROR|root|Error: ERROR while running predict for task footballfields
Traceback (most recent call last):
  File "/opt/miniconda3/envs/orthoseg/lib/python3.9/site-packages/orthoseg/predict.py", line 166, in predict
    best_model["filepath"].parent / best_model["filepath"].stem + "_optim"
TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/miniconda3/envs/orthoseg/lib/python3.9/site-packages/orthoseg/predict.py", line 294, in main
    predict_args(sys.argv[1:])
  File "/opt/miniconda3/envs/orthoseg/lib/python3.9/site-packages/orthoseg/predict.py", line 71, in predict_args
    predict(config_path=Path(args.config))
  File "/opt/miniconda3/envs/orthoseg/lib/python3.9/site-packages/orthoseg/predict.py", line 289, in predict
    raise Exception(message) from ex
Exception: ERROR while running predict for task footballfields
Traceback (most recent call last):
  File "/opt/miniconda3/envs/orthoseg/lib/python3.9/site-packages/orthoseg/predict.py", line 166, in predict
    best_model["filepath"].parent / best_model["filepath"].stem + "_optim"
TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/miniconda3/envs/orthoseg/bin/orthoseg_predict", line 8, in <module>
    sys.exit(main())
  File "/opt/miniconda3/envs/orthoseg/lib/python3.9/site-packages/orthoseg/predict.py", line 294, in main
    predict_args(sys.argv[1:])
  File "/opt/miniconda3/envs/orthoseg/lib/python3.9/site-packages/orthoseg/predict.py", line 71, in predict_args
    predict(config_path=Path(args.config))
  File "/opt/miniconda3/envs/orthoseg/lib/python3.9/site-packages/orthoseg/predict.py", line 289, in predict
    raise Exception(message) from ex
Exception: ERROR while running predict for task footballfields

Any ideas why?
orthoseg_env.txt

Add pre-simplify with RDP when using (inline) LANG simplification

The LANG simplification algorithm seems to give a smoother output than RDP and VW, but the number of points removed is limited by the lookahead parameter. Because the inline simplification during prediction works on the polygonized vector data there are a lot of points, so the limit by the LANG lookahead parameter is an issue.

By pre-simplifying the polygons with RDP using a smaller tolerance (eg. 50%) this disadvantage can be largely countered.

model file for sample projet not being downloaded

When running:
orthoseg_load_sampleprojects
to download the sample projects, the model file (.hdf5) being downloaded consists of HTML content rather than the HDF5 itself.

This appears to be happening because the model file is being downloaded from a Google Drive location and when trying to get the file, Google is instead sending an HTML page, saying that the file is too big to be scanned.

As a workaround, I downloaded the file myself directly from the Google link: https://drive.google.com/file/d/1XmAenCW6K_RVwqC6xbkapJ5ws-f7-QgH

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.