Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast fixes for compatibility with tensorflow 2.6 #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions keras_vggface/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
'''


from keras.layers import Flatten, Dense, Input, GlobalAveragePooling2D, \
from tensorflow.keras.layers import Flatten, Dense, Input, GlobalAveragePooling2D, \
GlobalMaxPooling2D, Activation, Conv2D, MaxPooling2D, BatchNormalization, \
AveragePooling2D, Reshape, Permute, multiply
#from tensorflow.keras.applications.imagenet_utils import _obtain_input_shape
from keras_applications.imagenet_utils import _obtain_input_shape
from keras.utils import layer_utils
from keras.utils.data_utils import get_file
from keras import backend as K
from tensorflow.python.keras.utils import layer_utils
from tensorflow.python.keras.utils.data_utils import get_file
from tensorflow.keras import backend as K
from keras_vggface import utils
from keras.engine.topology import get_source_inputs
#from tensorflow.keras.engine.topology import get_source_inputs
from tensorflow.keras.utils import get_source_inputs
import warnings
from keras.models import Model
from keras import layers
from tensorflow.keras.models import Model
from tensorflow.keras import layers


def VGG16(include_top=True, weights='vggface',
Expand Down
4 changes: 2 additions & 2 deletions keras_vggface/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


import numpy as np
from keras import backend as K
from keras.utils.data_utils import get_file
from tensorflow.keras import backend as K
from tensorflow.python.keras.utils.data_utils import get_file

V1_LABELS_PATH = 'https://github.com/rcmalli/keras-vggface/releases/download/v2.0/rcmalli_vggface_labels_v1.npy'
V2_LABELS_PATH = 'https://github.com/rcmalli/keras-vggface/releases/download/v2.0/rcmalli_vggface_labels_v2.npy'
Expand Down
6 changes: 3 additions & 3 deletions keras_vggface/version.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
__version__ = '0.6'

def pretty_versions():
import keras
import tensorflow.keras
import tensorflow as tf
k_version = keras.__version__
k_version = tensorflow.keras.__version__
t_version = tf.__version__
return "keras-vggface : {}, keras : {} , tensorflow : {} ".format(__version__,k_version,t_version)
return "keras-vggface : {}, keras : {} , tensorflow : {} ".format(__version__,k_version,t_version)
15 changes: 6 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
exec(open('keras_vggface/version.py').read())
setup(
name='keras_vggface',
version=__version__,
version=__version__ + '_vddk-0.1',
description='VGGFace implementation with Keras framework',
url='https://github.com/rcmalli/keras-vggface',
author='Refik Can MALLI',
url='https://github.com/DavidDoukhan/keras-vggface',
author='Refik Can MALLI & David Doukhan',
author_email="[email protected]",
license='MIT',
keywords=['keras', 'vggface', 'deeplearning'],
packages=find_packages(exclude=["tools", "training", "temp", "test", "data", "visualize","image",".venv",".github"]),
zip_safe=False,
install_requires=[
'numpy>=1.9.1', 'scipy>=0.14', 'h5py', 'pillow', 'keras',
'six>=1.9.0', 'pyyaml'
'numpy>=1.9.1', 'scipy>=0.14', 'h5py', 'pillow', 'tensorflow',
'six>=1.9.0', 'pyyaml', 'keras-applications'
],
extras_require={
"tf": ["tensorflow"],
"tf_gpu": ["tensorflow-gpu"],
})
)
10 changes: 5 additions & 5 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import numpy as np
from keras_vggface import VGGFace
from keras.preprocessing import image
from tensorflow.keras.preprocessing import image
from keras_vggface import utils
import keras
import tensorflow.keras
import unittest


class VGGFaceTests(unittest.TestCase):

def testVGG16(self):
keras.backend.image_data_format()
tensorflow.keras.backend.image_data_format()
model = VGGFace(model='vgg16')
img = image.load_img('image/ajb.jpg', target_size=(224, 224))
x = image.img_to_array(img)
Expand All @@ -23,7 +23,7 @@ def testVGG16(self):
self.assertAlmostEqual(utils.decode_predictions(preds)[0][0][1], 0.9790116, places=3)

def testRESNET50(self):
keras.backend.image_data_format()
tensorflow.keras.backend.image_data_format()
model = VGGFace(model='resnet50')
img = image.load_img('image/ajb.jpg', target_size=(224, 224))
x = image.img_to_array(img)
Expand All @@ -37,7 +37,7 @@ def testRESNET50(self):
self.assertAlmostEqual(utils.decode_predictions(preds)[0][0][1], 0.91819614, places=3)

def testSENET50(self):
keras.backend.image_data_format()
tensorflow.keras.backend.image_data_format()
model = VGGFace(model='senet50')
img = image.load_img('image/ajb.jpg', target_size=(224, 224))
x = image.img_to_array(img)
Expand Down
4 changes: 2 additions & 2 deletions tools/draw_networks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from keras.utils import plot_model
from tensorflow.keras.utils import plot_model
from keras_vggface import VGGFace

model = VGGFace(model='vgg16')
Expand All @@ -8,4 +8,4 @@
plot_model(model, to_file='resnet50.png', show_shapes=True)

model = VGGFace(model='senet50')
plot_model(model, to_file='senet50.png' ,show_shapes=True)
plot_model(model, to_file='senet50.png' ,show_shapes=True)