1
0
Fork 0
mirror of https://github.com/deepfakes/faceswap synced 2025-06-07 19:05:02 -04:00
faceswap/tests/startup_test.py
torzdf aa39234538
Update all Keras Imports to be conditional (#1214)
* Remove custom keras importer

* first round keras imports fix

* launcher.py: Remove KerasFinder references

* 2nd round keras imports update (lib and extract)

* 3rd round keras imports update (train)

* remove KerasFinder from tests

* 4th round keras imports update (tests)
2022-05-03 20:18:39 +01:00

36 lines
1.3 KiB
Python

#!/usr/bin/env python3
""" Sanity checks for Faceswap. """
import inspect
import pytest
from lib.utils import get_backend
if get_backend() == "amd":
import keras
from keras import backend as K
else:
# Ignore linting errors from Tensorflow's thoroughly broken import system
from tensorflow import keras
from tensorflow.keras import backend as K # pylint:disable=import-error
_BACKEND = get_backend()
@pytest.mark.parametrize('dummy', [None], ids=[get_backend().upper()])
def test_backend(dummy): # pylint:disable=unused-argument
""" Sanity check to ensure that Keras backend is returning the correct object type. """
test_var = K.variable((1, 1, 4, 4))
lib = inspect.getmodule(test_var).__name__.split(".")[0]
assert (_BACKEND == "cpu" and lib == "tensorflow") or (_BACKEND == "amd" and lib == "plaidml")
@pytest.mark.parametrize('dummy', [None], ids=[get_backend().upper()])
def test_keras(dummy): # pylint:disable=unused-argument
""" Sanity check to ensure that tensorflow keras is being used for CPU and standard
keras for AMD. """
assert ((_BACKEND == "cpu" and keras.__version__ in ("2.3.0-tf", "2.4.0",
"2.6.0", "2.7.0", "2.8.0")) or
(_BACKEND == "amd" and keras.__version__ == "2.2.4"))