Skip to content
Snippets Groups Projects
Commit 62bcdc10 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

Merge branch 'standarization' into 'master'

Standarization

I know that it still doesn't build on GitLab CI -- due to a wrong version of  ``Pillow`` (see #1). Anyways, I think it is time to merge this branch and go on pushing a new version of ``bob.bio.csu`` to PyPI.

I know that this is not sufficient, but I have installed that package locally on my machine, and I was able to build and execute it. Nose tests are passing; I haven't checked the documentation, though.

See merge request !1
parents bbaadf7b 33a9b513
No related branches found
No related tags found
1 merge request!1Standarization
Pipeline #
Showing with 147 additions and 181 deletions
......@@ -29,11 +29,17 @@ variables:
- git clean -ffdx
- curl --silent https://gitlab.idiap.ch/bob/bob/snippets/7/raw | tr -d '\r' > bootstrap-conda.sh
- chmod 755 ./bootstrap-conda.sh
- sed 1d -i requirements.txt # GAMBIT to remove pillow<3
- ./bootstrap-conda.sh ${CONDA_FOLDER} ${PYTHON_VER} ${CONDA_PREFIX}
variables: &build_variables
BOB_DOCUMENTATION_SERVER: "http://www.idiap.ch/software/bob/docs/latest/bob/%s/master/"
script:
- ./bin/buildout
- ./bin/buildout -c buildout-before-patch.cfg
- wget https://www.idiap.ch/software/bob/databases/latest/PythonFaceEvaluation.tar.bz2
- mkdir PythonFaceEvaluation
- tar -xjf PythonFaceEvaluation.tar.bz2 -C PythonFaceEvaluation
- ./bin/patch_CSU.py PythonFaceEvaluation
- ./bin/buildout buildout:csu-dir=./PythonFaceEvaluation
- if [ -x ./bin/bob_dbmanage.py ]; then ./bin/bob_dbmanage.py all download --force; fi
- ./bin/sphinx-build doc sphinx
- ./bin/python setup.py bdist_wheel --python-tag ${WHEEL_TAG}
......@@ -45,6 +51,7 @@ variables:
- bootstrap-conda.sh
- dist/
- sphinx/
- PythonFaceEvaluation/
# Template for building on a Linux machine
......@@ -74,11 +81,14 @@ variables:
.test_template: &test_job
stage: test
before_script:
- sed 1d -i requirements.txt # GAMBIT to remove pillow<3
- ./bootstrap-conda.sh ${CONDA_FOLDER} ${PYTHON_VER} ${CONDA_PREFIX}
- source ${CONDA_FOLDER}/bin/activate ${CONDA_PREFIX}
- pip install --use-wheel --no-index --pre dist/*.whl
- conda install --yes -c conda-forge -p ${CONDA_PREFIX} jpeg==9b opencv==2.4.12
- pip install --use-wheel --no-index --pre dist/*.whl
script:
- cd ${CONDA_PREFIX}
- cd ${CONDA_PREFIX}
- export PYTHONPATH="../PythonFaceEvaluation/src:$PYTHONPATH"
- python -c "from ${CI_PROJECT_NAME} import get_config; print(get_config())"
- coverage run --source=${CI_PROJECT_NAME} ./bin/nosetests -sv ${CI_PROJECT_NAME}
- coverage report
......@@ -137,118 +147,17 @@ test_linux_27:
tags:
- conda-linux
wheels_linux_27:
<<: *wheels_job
docs_linux_27:
<<: *docs_job
dependencies:
- build_linux_27
tags:
- conda-linux
# Linux + Python 3.4: Builds and tests
build_linux_34:
<<: *linux_build_job
variables: &linux_34_build_variables
<<: *linux_build_variables
PYTHON_VER: "3.4"
WHEEL_TAG: "py3"
tags:
- conda-linux
test_linux_34:
<<: *test_job
variables: *linux_34_build_variables
dependencies:
- build_linux_34
tags:
- conda-linux
# Linux + Python 3.5: Builds, tests, uploads wheel
build_linux_35:
<<: *linux_build_job
variables: &linux_35_build_variables
<<: *linux_build_variables
PYTHON_VER: "3.5"
WHEEL_TAG: "py3"
tags:
- conda-linux
test_linux_35:
<<: *test_job
variables: *linux_35_build_variables
dependencies:
- build_linux_35
tags:
- conda-linux
wheels_linux_35:
wheels_linux_27:
<<: *wheels_job
dependencies:
- build_linux_35
tags:
- conda-linux
docs_linux_35:
<<: *docs_job
dependencies:
- build_linux_35
- build_linux_27
tags:
- conda-linux
# Mac OSX + Python 2.7: Builds and tests
build_macosx_27:
<<: *macosx_build_job
variables: &macosx_27_build_variables
<<: *macosx_build_variables
PYTHON_VER: "2.7"
WHEEL_TAG: "py27"
tags:
- conda-macosx
test_macosx_27:
<<: *test_job
variables: *macosx_27_build_variables
dependencies:
- build_macosx_27
tags:
- conda-macosx
# Mac OSX + Python 3.4: Builds and tests
build_macosx_34:
<<: *macosx_build_job
variables: &macosx_34_build_variables
<<: *macosx_build_variables
PYTHON_VER: "3.4"
WHEEL_TAG: "py3"
tags:
- conda-macosx
test_macosx_34:
<<: *test_job
variables: *macosx_34_build_variables
dependencies:
- build_macosx_34
tags:
- conda-macosx
# Mac OSX + Python 3.5: Builds and tests
build_macosx_35:
<<: *macosx_build_job
variables: &macosx_35_build_variables
<<: *macosx_build_variables
PYTHON_VER: "3.5"
WHEEL_TAG: "py3"
tags:
- conda-macosx
test_macosx_35:
<<: *test_job
variables: *macosx_35_build_variables
dependencies:
- build_macosx_35
tags:
- conda-macosx
\ No newline at end of file
......@@ -7,7 +7,7 @@ import bob.bio.base
from .. import utils
class LDAIR (bob.bio.base.algorithm.Algorithm):
"""This class defines a wrapper for the :py:class:`facerec2010.baseline.lda.LRLDA` class to be used as an image :py:class:`bob.bio.base.algorithm.Algorithm`.
"""This class defines a wrapper for the `facerec2010.baseline.lda.LRLDA` class to be used as an image :py:class:`bob.bio.base.algorithm.Algorithm`.
**Parameters:**
......@@ -66,12 +66,12 @@ class LDAIR (bob.bio.base.algorithm.Algorithm):
**Parameters:**
enroll_features : [:py:class:`facerec2010.baseline.common.FaceRecord`]
enroll_features : [`facerec2010.baseline.common.FaceRecord`]
The features used to enroll the model.
**Returns:**
model : [:py:class:`facerec2010.baseline.common.FaceRecord`]
model : [`facerec2010.baseline.common.FaceRecord`]
The model, which is identical to the ``enroll_features``.
"""
[self._check_feature(f) for f in enroll_features]
......@@ -85,7 +85,7 @@ class LDAIR (bob.bio.base.algorithm.Algorithm):
**Parameters:**
model : [:py:class:`facerec2010.baseline.common.FaceRecord`]
model : [`facerec2010.baseline.common.FaceRecord`]
The model to be written.
model_file : str
......@@ -107,7 +107,7 @@ class LDAIR (bob.bio.base.algorithm.Algorithm):
**Returns:**
model : [:py:class:`facerec2010.baseline.common.FaceRecord`]
model : [`facerec2010.baseline.common.FaceRecord`]
The model read from file.
"""
# just read the model from .pkl file
......@@ -123,10 +123,10 @@ class LDAIR (bob.bio.base.algorithm.Algorithm):
**Parameters:**
model : [:py:class:`facerec2010.baseline.common.FaceRecord`]
model : [`facerec2010.baseline.common.FaceRecord`]
The model to compare, which is actually a list of extracted features.
probe : :py:class:`facerec2010.baseline.common.FaceRecord`
probe : `facerec2010.baseline.common.FaceRecord`
The probe to compare.
**Returns**:
......
......@@ -9,7 +9,7 @@ from .. import utils
class LRPCA (bob.bio.base.algorithm.Algorithm):
"""This class defines a wrapper for the :py:class:`facerec2010.baseline.lda.LRPCA` class to be used as an image :py:class:`bob.bio.base.algorithm.Algorithm`.
"""This class defines a wrapper for the `facerec2010.baseline.lda.LRPCA` class to be used as an image :py:class:`bob.bio.base.algorithm.Algorithm`.
**Parameters:**
......@@ -58,7 +58,7 @@ class LRPCA (bob.bio.base.algorithm.Algorithm):
**Returns:**
model : [:py:class:`facerec2010.baseline.pca.FaceRecord`]
model : [`facerec2010.baseline.pca.FaceRecord`]
The model, which a collection of face records, storing the given ``enroll_features``.
"""
# no rule to enroll features in the LRPCA setup, so we just store all features
......@@ -76,7 +76,7 @@ class LRPCA (bob.bio.base.algorithm.Algorithm):
**Parameters:**
model : [:py:class:`facerec2010.baseline.pca.FaceRecord`]
model : [`facerec2010.baseline.pca.FaceRecord`]
The model to be written.
model_file : str
......@@ -98,7 +98,7 @@ class LRPCA (bob.bio.base.algorithm.Algorithm):
**Returns:**
model : [:py:class:`facerec2010.baseline.pca.FaceRecord`]
model : [`facerec2010.baseline.pca.FaceRecord`]
The model read from file.
"""
# just read the model from .pkl file
......@@ -112,7 +112,7 @@ class LRPCA (bob.bio.base.algorithm.Algorithm):
**Parameters:**
model : [:py:class:`facerec2010.baseline.pca.FaceRecord`]
model : [`facerec2010.baseline.pca.FaceRecord`]
The model to compare, which is actually a list of extracted features.
probe : :py:class:`numpy.ndarray`
......
......@@ -13,7 +13,7 @@ logger = logging.getLogger("bob.bio.csu")
from .. import utils
class LDAIR (bob.bio.base.extractor.Extractor):
"""This class defines a wrapper for the :py:class:`facerec2010.baseline.lda.LRLDA` class to be used as an image :py:class:`bob.bio.base.extractor.Extractor`.
"""This class defines a wrapper for the `facerec2010.baseline.lda.LRLDA` class to be used as an image :py:class:`bob.bio.base.extractor.Extractor`.
**Parameters:**
......@@ -127,7 +127,7 @@ class LDAIR (bob.bio.base.extractor.Extractor):
**Returns:**
extracted : :py:class:`facerec2010.baseline.common.FaceRecord`
extracted : `facerec2010.baseline.common.FaceRecord`
The extracted image feature.
"""
self._check_image(image)
......@@ -144,7 +144,7 @@ class LDAIR (bob.bio.base.extractor.Extractor):
**Parameters:**
feature : :py:class:`facerec2010.baseline.common.FaceRecord`
feature : `facerec2010.baseline.common.FaceRecord`
The extracted feature to be written.
feature_file : str or :py:class:`bob.io.base.HDF5File`
......@@ -167,7 +167,7 @@ class LDAIR (bob.bio.base.extractor.Extractor):
**Returns:**
feature : :py:class:`facerec2010.baseline.common.FaceRecord`
feature : `facerec2010.baseline.common.FaceRecord`
The read feature.
"""
# read the feature from .pkl file
......
......@@ -13,7 +13,7 @@ import logging
logger = logging.getLogger("bob.bio.csu")
class LRPCA (bob.bio.base.extractor.Extractor):
"""This class defines a wrapper for the :py:class:`facerec2010.baseline.lda.LRPCA` class to be used as an image :py:class:`bob.bio.base.extractor.Extractor`.
"""This class defines a wrapper for the `facerec2010.baseline.lda.LRPCA` class to be used as an image :py:class:`bob.bio.base.extractor.Extractor`.
**Parameters:**
......
......@@ -6,9 +6,10 @@ import pyvision
import numpy
import bob.bio.base
import bob.bio.face
from .. import utils
class LDAIR (bob.bio.face.preprocessor.FaceCrop):
"""This class defines a wrapper for the :py:class:`facerec2010.baseline.lda.LRLDA` class to be used as an image :py:class:`bob.bio.base.preprocessor.Preprocessor`.
"""This class defines a wrapper for the `facerec2010.baseline.lda.LRLDA` class to be used as an image :py:class:`bob.bio.base.preprocessor.Preprocessor`.
**Parameters:**
......@@ -24,11 +25,18 @@ class LDAIR (bob.bio.face.preprocessor.FaceCrop):
"""
def __init__(self, REGION_ARGS = facerec2010.baseline.lda.CohortLDA_REGIONS, REGION_KEYWORDS = facerec2010.baseline.lda.CohortLDA_KEYWORDS, face_detector = None):
bob.bio.base.preprocessor.Preprocessor.__init__(self, REGION_ARGS=str(REGION_ARGS), REGION_KEYWORDS=str(REGION_KEYWORDS), face_detector=str(face_detector))
bob.bio.base.preprocessor.Preprocessor.__init__(
self,
read_original_data=utils.read_pyvision_image,
face_detector=str(face_detector),
REGION_ARGS=str(REGION_ARGS),
REGION_KEYWORDS=str(REGION_KEYWORDS),
)
self.ldair = facerec2010.baseline.lda.LRLDA(REGION_ARGS, **REGION_KEYWORDS)
self.layers = len(REGION_ARGS)
self.face_detector = bob.bio.face.preprocessor.utils.load_cropper(face_detector)
if self.face_detector is not None:
assert isinstance(self.face_detector, bob.bio.face.preprocessor.FaceDetect)
# asign ourself to be the face cropper that should be used after face detection
......@@ -116,29 +124,7 @@ class LDAIR (bob.bio.face.preprocessor.FaceCrop):
if isinstance(image, pyvision.Image):
# the face detector requires numpy arrays
image = self._numpy_image(image)
import bob.io.base
import bob.io.image
bob.io.base.save(image.astype(numpy.uint8), "test.png")
# call face detector with the (tansformed) image
return self.face_detector.crop_face(image, annotations)
return self.crop_face(image, annotations)
def read_original_data(self, image_file):
"""read_original_data(image_file) -> image
Reads the original images using functionality from pyvision.
**Parameters:**
image_file : str
The image file to be read, can contain a gray level or a color image.
**Returns:**
image : :py:class:`pyvision.Image`
The image read from file.
"""
# we use pyvision to read the images. Hence, we don't have to struggle with conversion here
return pyvision.Image(str(image_file))
......@@ -7,6 +7,8 @@ import PIL
import numpy
import bob.bio.base
import bob.bio.face
from .. import utils
class LRPCA (bob.bio.face.preprocessor.FaceCrop):
"""This class defines a wrapper for the :py:class:`facerec2010.baseline.lda.LRPCA` class to be used as an image :py:class:`bob.bio.base.preprocessor.Preprocessor`.
......@@ -22,7 +24,12 @@ class LRPCA (bob.bio.face.preprocessor.FaceCrop):
"""
def __init__(self, TUNING = facerec2010.baseline.lrpca.GBU_TUNING, face_detector = None):
bob.bio.base.preprocessor.Preprocessor.__init__(self, TUNING=str(TUNING), face_detector=str(face_detector))
bob.bio.base.preprocessor.Preprocessor.__init__(
self,
read_original_data=utils.read_pyvision_image,
face_detector=str(face_detector),
TUNING=str(TUNING)
)
self.lrpca = facerec2010.baseline.lrpca.LRPCA(**TUNING)
self.face_detector = bob.bio.face.preprocessor.utils.load_cropper(face_detector)
......@@ -111,23 +118,3 @@ class LRPCA (bob.bio.face.preprocessor.FaceCrop):
return self.face_detector.crop_face(image, annotations)
return self.crop_face(image, annotations)
def read_original_data(self, image_file):
"""read_original_data(image_file) -> image
Reads the original images using functionality from pyvision.
**Parameters:**
image_file : str
The image file to be read, can contain a gray level or a color image.
**Returns:**
image : :py:class:`pyvision.Image`
The image read from file.
"""
# we use pyvision to read the images. Hence, we don't have to struggle with conversion here
return pyvision.Image(str(image_file))
No preview for this file type
No preview for this file type
......@@ -15,11 +15,22 @@ regenerate_refs = False
import bob.bio.base
import bob.bio.face
from bob.bio.face.test.test_preprocessors import _annotation, _compare
from bob.bio.face.test.test_preprocessors import _annotation
def _compare(data, reference, write_function = bob.bio.base.save, read_function = bob.bio.base.load, atol = 1e-5, rtol = 1e-8):
# write reference?
if regenerate_refs:
write_function(data, reference)
# compare reference
reference = read_function(reference)
assert numpy.allclose(data, reference, atol=atol, rtol=rtol)
return reference
def _image(preprocessor):
return preprocessor.read_original_data(pkg_resources.resource_filename('bob.bio.face.test', 'data/testimage.jpg'))
f = bob.bio.base.database.BioFile(1, 'data/testimage', 2)
return preprocessor.read_original_data(f, pkg_resources.resource_filename('bob.bio.face', 'test'), ".jpg")
def test_lrpca():
......
......@@ -3,6 +3,7 @@
import pickle
import bob.io.base
import pyvision
def load_pickle(file_like):
"""load_pickle(file_like) -> data
......@@ -42,3 +43,28 @@ def save_pickle(data, file_like):
hdf5 = file_like if isinstance(file_like, bob.io.base.HDF5File) else bob.io.base.HDF5File(file_like, 'w')
hdf5.set("Data", pickle.dumps(data))
def read_pyvision_image(biofile, directory, extension):
"""read_pyvision_image(biofile, directory, extension) -> image
Reads the original images using functionality from pyvision.
**Parameters:**
``biofile`` : :py:class:`bob.bio.base.database.BioFile` or one of its derivatives
The file to read the original data.
``directory`` : str
The base directory of the database.
``extension`` : str or ``None``
The extension of the original data.
Might be ``None`` if the ``biofile`` itself has the extension stored.
**Returns:**
image : :py:class:`pyvision.Image`
The image read from file.
"""
return pyvision.Image(biofile.make_path(directory, extension))
build.sh 0 → 100644
#!/usr/bin/env bash
# Wed 21 Sep 2016 13:08:05 CEST
source $(dirname ${0})/functions.sh
run_cmd ./bin/buildout -c buildout-before-patch.cfg
run_cmd wget https://www.idiap.ch/software/bob/databases/latest/PythonFaceEvaluation.tar.bz2
run_cmd mkdir PythonFaceEvaluation
run_cmd tar -xjf PythonFaceEvaluation.tar.bz2 -C PythonFaceEvaluation
run_cmd ./bin/patch_CSU.py PythonFaceEvaluation
run_cmd ./bin/buildout buildout:csu-dir=./PythonFaceEvaluation
export PYTHONPATH="PythonFaceEvaluation:$PYTHONPATH"
if [ -x ./bin/bob_dbmanage.py ]; then
run_cmd ./bin/bob_dbmanage.py all download --force;
fi
if [ -d ./doc ]; then
run_cmd ./bin/sphinx-build -n doc sphinx
fi
if [ -z "${WHEEL_TAG}" ]; then
# C/C++ extensions
run_cmd ./bin/python setup.py bdist_wheel
else
# Python-only packages
run_cmd ./bin/python setup.py bdist_wheel --python-tag ${WHEEL_TAG}
fi
......@@ -4,11 +4,17 @@
[buildout]
parts = scripts
develop = .
${buildout:csu-dir}
eggs = bob.bio.csu
PythonFaceEvaluation
extensions = bob.buildout
newest = false
verbose = true
csu-dir = [PATH_TO_YOUR_CSU_COPY]
[scripts]
recipe = bob.buildout:scripts
dependent-scripts = true
\ No newline at end of file
dependent-scripts = true
......@@ -30,7 +30,6 @@ develop = src/bob.extension
src/bob.learn.em
src/bob.measure
src/bob.db.base
src/bob.bio.db
src/bob.db.atnt
src/bob.bio.base
src/bob.learn.boosting
......@@ -64,7 +63,6 @@ bob.learn.linear = git https://gitlab.idiap.ch/bob/bob.learn.linear
bob.learn.em = git https://gitlab.idiap.ch/bob/bob.learn.em
bob.measure = git https://gitlab.idiap.ch/bob/bob.measure
bob.db.base = git https://gitlab.idiap.ch/bob/bob.db.base
bob.bio.db = git https://gitlab.idiap.ch/bob/bob.bio.db
bob.db.atnt = git https://gitlab.idiap.ch/bob/bob.db.atnt
bob.bio.base = git https://gitlab.idiap.ch/bob/bob.bio.base
bob.learn.boosting = git https://gitlab.idiap.ch/bob/bob.learn.boosting
......
......@@ -37,7 +37,7 @@ If you haven't patched it yet, please follow the set of instructions:
$ ./bin/patch_CSU.py [PATH_TO_YOUR_CSU_COPY]
If you get any error message, the sources of the CSU might have changed (the latest test was done in December 2012).
Please file a bug report in `our GitHub page <http://www.github.com/bioidiap/xfacereclib.extension.CSU>`_ to inform us so that we can provide a new patch.
Please file a bug report in `our google groups page <https://groups.google.com/forum/#!forum/bob-devel>`_ to inform us so that we can provide a new patch.
4. Update the CSU toolkit path in the *buildout.cfg* file by setting the ``csu-dir`` variable via replacing the ``[PATH_TO_YOUR_CSU_COPY]`` with your actual directory:
......
......@@ -20,8 +20,8 @@ setup(
url = 'https://gitlab.idiap.ch/bob/bob.bio.csu',
license = 'BSD',
author = 'Amir Mohammadi',
author_email = 'amir.mohammadi@idiap.ch',
author = 'Manuel Gunther',
author_email = 'siebenkopf@googlemail.com',
keywords = 'bob',
# If you have a better, long description of your package, place it on the
......
test.sh 0 → 100644
#!/usr/bin/env bash
# Wed 21 Sep 2016 13:08:05 CEST
source $(dirname ${0})/functions.sh
run_cmd cd ${PREFIX}
run_cmd export PYTHONPATH=\"../PythonFaceEvaluation/src:$PYTHONPATH\"
# The tests:
run_cmd ${PREFIX}/bin/python ${BOB_PREFIX_PATH}/bin/coverage run --source=${CI_PROJECT_NAME} ${BOB_PREFIX_PATH}/bin/nosetests -sv ${CI_PROJECT_NAME}
run_cmd ${PREFIX}/bin/python ${BOB_PREFIX_PATH}/bin/coverage report
run_cmd ${PREFIX}/bin/python ${BOB_PREFIX_PATH}/bin/sphinx-build -b doctest ${CI_PROJECT_DIR}/doc ${CI_PROJECT_NAME}/sphinx
run_cmd cd ${CI_PROJECT_DIR}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment