Using TensorFlow backend

Issue

I program facial recognition and to use the "facenet_keras.h5" file I have to go through tensorflow but this error blocks me. help please, thank you.

this is the code:

import os
from os import listdir
from PIL import Image as Img
from numpy import asarray
from numpy import expand_dims
from keras.models import load_model
import numpy as np

import pickle
import cv2

#charger classifier et facenet_keras


HaarCascade = cv2.CascadeClassifier(cv2.samples.findFile(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml'))
MyFaceNet = load_model("facenet_keras.h5")


folder = 'photos/' #chemin dossier photos
database = {}

for filename in listdir(folder):

    path = folder + filename
    gbr1 = cv2.imread(path)

    visage = HaarCascade.detectMultiScale(gbr1, 1.1, 4)

    if len(visage) > 0:
        x1, y1, width, height = visage[0]
    else:
        x1, y1, width, height = 1, 1, 10, 10

    x1, y1 = abs(x1), abs(y1)
    x2, y2 = x1 + width, y1 + height

    gbr = cv2.cvtColor(gbr1, cv2.COLOR_BGR2RGB)
    gbr = Img.fromarray(gbr)  # conversion file OpenCV en PIL
    gbr_array = asarray(gbr)  #convert en tab

    face = gbr_array[y1:y2, x1:x2]  #prendre face fotsiny

    face = Img.fromarray(face)  # retour en img
    face = face.resize((160, 160))
    face = asarray(face)

    #normaliser entree
    face = face.astype('float32')
    mean, std = face.mean(), face.std() #moyenne et ecart type
    face = (face - mean) / std

    # envoie des entree a facenet
    face = expand_dims(face, axis=0)
    signature = MyFaceNet.predict(face)

    database[os.path.splitext(filename)[0]] = signature

myfile = open("data.pkl", "wb")
pickle.dump(database, myfile)
myfile.close()

myfile = open("data.pkl", "rb")
database = pickle.load(myfile)
myfile.close()

I program facial recognition and to use the "facenet_keras.h5" file I have to go through tensorflow but this error blocks me. help please, thank you.I program facial recognition and to use the "facenet_keras.h5" file I have to go through tensorflow but this error blocks me. help please, thank you.I program facial recognition and to use the "facenet_keras.h5" file I have to go through tensorflow but this error blocks me. help please, thank you.I program facial recognition and to use the "facenet_keras.h5" file I have to go through tensorflow but this error blocks me. help please, thank you.I program facial recognition and to use the "facenet_keras.h5" file I have to go through tensorflow but this error blocks me. help please, thank you.I program facial recognition and to use the "facenet_keras.h5" file I have to go through tensorflow but this error blocks me. help please, thank you.

this is the error:

Using TensorFlow backend.
C:\Users\Zouzou\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:458: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\Users\Zouzou\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:459: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\Users\Zouzou\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:460: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Users\Zouzou\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:461: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\Users\Zouzou\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:462: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\Users\Zouzou\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:465: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
2022-10-12 15:26:25.360069: W C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
C:\Users\Zouzou\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\models.py:252: UserWarning: No training configuration found in save file: the model was *not* compiled. Compile it manually.
  warnings.warn('No training configuration found in save file: '

Solution

I finally solved the problem. I had badly installed keras. pip install keras or reinstall tensorflow.

Answered By – h81 edrick

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published