Skip to content

Commit 24f7fdd

Browse files
committed
Refactoring of training and prediction code. Added more tests.
1 parent 029b4ab commit 24f7fdd

30 files changed

+1864
-263
lines changed

.travis.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
language: python
22
matrix:
33
include:
4-
- name: "Python 3.7 on Xenial Linux"
4+
- name: "Python 3.7 on Bionic Linux"
55
python: 3.7
6-
dist: xenial
6+
dist: bionic
77
env:
88
- PIP_CMD=pip3
99
- PYTHON=python3
@@ -17,20 +17,14 @@ matrix:
1717
env:
1818
- PIP_CMD=pip3
1919
- PYTHON=python3
20-
- name: "Python 3.6 on Xenial Linux"
20+
- name: "Python 3.6 on Bionic Linux"
2121
python: 3.6
22-
dist: xenial
23-
env:
24-
- PIP_CMD=pip3
25-
- PYTHON=python3
26-
- name: "Python 3.5 on Xenial Linux"
27-
python: 3.5
28-
dist: xenial
22+
dist: bionic
2923
env:
3024
- PIP_CMD=pip3
3125
- PYTHON=python3
3226
install:
3327
- $PIP_CMD install --upgrade pip
3428
- $PIP_CMD install -r requirements.txt
3529
- $PIP_CMD install .
36-
script: $PYTHON -m pytest
30+
script: $PYTHON -m pytest -v -s

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/examples/predictv3.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
data_source: !!python/object/apply:hugin.io.FileSystemLoader
2+
kwds:
3+
data_pattern: '(?P<name>[0-9A-Za-z_]+)__(?P<idx>[A-Za-z0-9_\.]+)_(?P<type>B.*)\.tif$'
4+
id_format: '{name}-{idx}'
5+
type_format: '{type}'
6+
input_source: /Users/mneagul/Downloads/S2A_OPER_MSI_L1C_TL_SGS__20170519T130610_A009957_T34TFQ_N02.05/data/rezolutie_nativa # Change to the path to the prediction data (can be changed at runtime)
7+
8+
9+
predictor: !!python/object/apply:hugin.infer.scene.AvgEnsembleScenePredictor
10+
kwds:
11+
name: interesting-ensemble
12+
predictors:
13+
- predictor: !!python/object/apply:hugin.infer.scene.RasterScenePredictor
14+
kwds:
15+
name: raster_predictor1
16+
model: !!python/object/apply:hugin.infer.core.KerasPredictor
17+
kwds:
18+
name: keras_predictor1
19+
model_path: /Users/mneagul/Work/Temp/mdl/forestry_training-09.hdf5
20+
model_builder: hugin.models.unet.unetv14:unet_v14
21+
input_shape: [256, 256]
22+
mapping:
23+
inputs:
24+
- [ "B02_10m", 1 ]
25+
- [ "B03_10m", 1 ]
26+
- [ "B04_10m", 1 ]
27+
- [ "B08_10m", 1 ]
28+
target:
29+
- [ "B01_10m_GTI", 1]
30+
prediction_merger: !!python/name:hugin.infer.core.AverageMerger
31+
weight: 1
32+
post_processors:
33+
#- !!python/name:hugin.engine.core.identity_processor
34+
- !!python/object/apply:hugin.infer.core.CategoricalConverter
35+
kwds:
36+
num_classes: 6
37+
metrics:
38+
metric_1: !!python/name:hugin.infer.core.identity_metric
39+
metric_2: !!python/name:hugin.infer.core.identity_metric
40+
gti_component: 'B01_10m_GTI'
41+
42+
output: !!python/object/apply:hugin.infer.scene.RasterIOSceneExporter
43+
kwds:
44+
destination: "/Users/mneagul/Work/Temp/export/"
45+
metric_destination: "/Users/mneagul/Work/Temp/export/metrics.txt"
46+
srs_source_component: "B02_10m"
47+
rasterio_creation_options:
48+
blockxsize: 256
49+
blockysize: 256
50+

docs/examples/trainv2.yaml

Whitespace-only changes.

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/conf.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
# import os
14+
# import sys
15+
# sys.path.insert(0, os.path.abspath('.'))
16+
17+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = 'Hugin EO'
21+
copyright = '2019, HuginEO Contributors'
22+
author = 'Marian Neagul, Teodora Selea, Gabriel Iuhasz, Alexandru Munteanu'
23+
24+
# The full version, including alpha/beta/rc tags
25+
release = '0.2.0'
26+
27+
28+
# -- General configuration ---------------------------------------------------
29+
30+
# Add any Sphinx extension module names here, as strings. They can be
31+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
32+
# ones.
33+
extensions = [
34+
'recommonmark',
35+
'sphinx_rtd_theme'
36+
]
37+
38+
master_doc = 'index'
39+
40+
# Add any paths that contain templates here, relative to this directory.
41+
templates_path = ['_templates']
42+
43+
# List of patterns, relative to source directory, that match files and
44+
# directories to ignore when looking for source files.
45+
# This pattern also affects html_static_path and html_extra_path.
46+
exclude_patterns = []
47+
48+
49+
# -- Options for HTML output -------------------------------------------------
50+
51+
# The theme to use for HTML and HTML Help pages. See the documentation for
52+
# a list of builtin themes.
53+
#
54+
html_theme = 'sphinx_rtd_theme'
55+
56+
# Add any paths that contain custom static files (such as style sheets) here,
57+
# relative to this directory. They are copied after the builtin static files,
58+
# so a file named "default.css" will overwrite the builtin "default.css".
59+
html_static_path = ['_static']

docs/source/index.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
==========================================================
2+
Hugin EO: Machine Learning for Earth Observation made easy
3+
==========================================================
4+
5+
Hugin helps scientists run Machine Learning experiments on geospatial raster data.
6+
7+
Hugin was developed as part of the ESA funded ML4EO_
8+
9+
Overall Hugin aims to facilitate experimentation with multiple machine learning problems, like:
10+
* Classification
11+
* Segmentation
12+
* Super-Resolution
13+
14+
Currently Hugin builds on top of the Keras machine learning library but it also aims to support, in the future, additional backends like scikit-learn.
15+
16+
.. toctree::
17+
:maxdepth: 2
18+
19+
intro
20+
installation
21+
quickstart
22+
topics/index
23+
api/index
24+
contributing
25+
faq
26+
27+
28+
29+
.. _ML4EO: http://sage.ieat.ro/projects/ML4EO/

docs/source/installation.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Hugin EO Installation
2+
=====================

docs/watch.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
fswatch -o .. | xargs -n1 make html

readthedocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
python:
2+
version: 3
3+
pip_install: true

setup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
'Fiona',
1616
'h5py',
1717
'backoff',
18-
'matplotlib<3.1',
18+
'matplotlib',
1919
'scikit-learn',
20-
'imgaug'
2120
]
2221

2322
def extra_files(directory):
@@ -37,5 +36,8 @@ def extra_files(directory):
3736
entry_points = {
3837
'console_scripts': ['hugin=hugin.tools.cli:main'],
3938
},
40-
description='Hugin ML4EO experimentation tool'
39+
description='Hugin ML4EO experimentation tool',
40+
extras_require = {
41+
'hugin_data_augmentation': ["imgaug"]
42+
}
4143
)

src/hugin/_data/logging-config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ version: 1
22
formatters:
33
brief:
44
format: '%(message)s'
5-
default:
5+
hugindefault:
66
format: "%(asctime)s %(filename)12s:%(lineno)d\t%(levelname)-8s %(name)-18s %(message)s"
77
datefmt: '%Y-%m-%d %H:%M:%S'
88
handlers:
99
console:
1010
class : logging.StreamHandler
11-
formatter: default
11+
formatter: hugindefault
1212
level : DEBUG
1313
stream : ext://sys.stderr
1414
loggers:
1515
hugin:
1616
handlers: [console, ]
1717
level: DEBUG
18+

src/hugin/engine/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)