diff --git a/.travis.yml b/.travis.yml index 47b078c99..875489f0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,20 +2,41 @@ language: python sudo: required -python: - - '2.7' - - '3.6' +matrix: + include: + #- python: 2.7 + # dist: xenial # Ubuntu 16.04 + # env: TOXENV=py27 + - python: 3.5 + dist: xenial # Ubuntu 16.04 + env: TF_VERSION="tensorflow<2.0" + - python: 3.6 + dist: bionic # Ubuntu 18.04 + env: TF_VERSION="tensorflow<2.0" + - python: 3.7 + dist: bionic # Ubuntu 18.04 + env: TF_VERSION="tensorflow<2.0" + - python: 3.6 + dist: bionic # Ubuntu 18.04 + env: TF_VERSION="tensorflow>=2.0" + - python: 3.7 + dist: bionic # Ubuntu 18.04 + env: TF_VERSION="tensorflow>=2.0" + +cache: pip install: + # see: https://github.com/fizyr/keras-retinanet/issues/1123#issuecomment-541566486 + - pip install $TF_VERSION - pip install -r requirements.txt - pip install -r tests/requirements.txt - -cache: pip + - pip list script: - python setup.py check -m -s - python setup.py build_ext --inplace - - travis_wait coverage run --source keras_retinanet -m py.test keras_retinanet tests --doctest-modules --forked --flake8 + - python setup.py install --dry-run + - coverage run --source keras_retinanet -m py.test keras_retinanet tests --doctest-modules --forked --flake8 after_success: - coverage xml diff --git a/keras_retinanet/backend/__init__.py b/keras_retinanet/backend/__init__.py index 4bace6940..faaa440e9 100644 --- a/keras_retinanet/backend/__init__.py +++ b/keras_retinanet/backend/__init__.py @@ -1,2 +1,15 @@ +import tensorflow + +# parse the tensorflow version +tf_version = [int(i) for i in tensorflow.__version__.split('.')] +if tf_version[0] >= 2: + # Disable Tensorflow 2.x behavior as we experience issues with it. + # see: https://www.tensorflow.org/api_docs/python/tf/compat/v1/disable_v2_behavior + tensorflow.compat.v1.disable_v2_behavior() + # for cases of using `x.numpy()` + # Aiming: NotImplementedError: numpy() is only available when eager execution is enabled. + # see: https://www.tensorflow.org/api_docs/python/tf/compat/v1/enable_eager_execution + tensorflow.compat.v1.enable_eager_execution() + from .dynamic import * # noqa: F401,F403 from .common import * # noqa: F401,F403 diff --git a/tests/models/test_densenet.py b/tests/models/test_densenet.py index 595fb5672..f571d2f37 100644 --- a/tests/models/test_densenet.py +++ b/tests/models/test_densenet.py @@ -48,4 +48,4 @@ def test_backbone(backbone): }, optimizer=keras.optimizers.adam(lr=1e-5, clipnorm=0.001)) - model.fit(inputs, targets, batch_size=1) + model.fit(inputs, targets, batch_size=1, epochs=1)