Giter Club home page Giter Club logo

face-recognition-using-deep-learning's People

Contributors

sumantrajoshi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

face-recognition-using-deep-learning's Issues

Train with own dataset

Hi

I want to train with my own dataset. How to do that. I also want to use pre trained model but still want to train with new dataset.

Thanks.

resizing failed

I followed your tutorial, I get the following error:
""
File "", line 1, in
File "C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/alhus/Desktop/DeepFace Detecrion/main.py", line 371, in
input_embeddings = create_input_image_embeddings()
File "C:/Users/alhus/Desktop/DeepFace Detecrion/main.py", line 297, in create_input_image_embeddings
input_embeddings[person_name] = image_to_embedding(image_file, model)
File "C:/Users/alhus/Desktop/DeepFace Detecrion/main.py", line 257, in image_to_embedding
image = cv2.resize(image, (152, 152))
cv2.error: OpenCV(4.3.0) C:\projects\opencv-python\opencv\modules\imgproc\src\resize.cpp:3929: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'

""

what is the reason for this error and how to fix it.
Thanks in advance.

code, below:

`
def image_to_embedding(image, model):
image = cv2.resize(image, (152, 152))
img = image[...,::-1]
img = np.around(np.transpose(img, (0,1,2))/255.0, decimals=12)
x_train = np.array([img])
embedding = model.predict_on_batch(x_train)
return embedding

def recognize_face(face_image, input_embeddings, model):
embedding = image_to_embedding(face_image, model)

minimum_distance = 200
name = None

# Loop over  names and encodings.
for (input_name, input_embedding) in input_embeddings.items():

    euclidean_distance = np.linalg.norm(embedding - input_embedding)

    print('Euclidean distance from %s is %s' % (input_name, euclidean_distance))

    if euclidean_distance < minimum_distance:
        minimum_distance = euclidean_distance
        name = input_name

if minimum_distance < 0.68:
    return str(name)
else:
    return None

import glob

def create_input_image_embeddings():
input_embeddings = {}

for file in glob.glob("C:\\Users\\alhus\\Desktop\\cr7 photos"):
    person_name = os.path.splitext(os.path.basename(file))[0]
    image_file = cv2.imread(file, 1)
    input_embeddings[person_name] = image_to_embedding(image_file, model)

return input_embeddings

def recognize_faces_in_cam(input_embeddings):
cv2.namedWindow("Face Recognizer")
vc = cv2.VideoCapture(0)

font = cv2.FONT_HERSHEY_SIMPLEX
face_cascade = face_detector

while vc.isOpened():
    _, frame = vc.read()
    img = frame
    height, width, channels = frame.shape

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    faces = face_cascade.detectMultiScale(gray, 1.3, 5)

    # Loop through all the faces detected
    identities = []
    for (x, y, w, h) in faces:
        x1 = x
        y1 = y
        x2 = x + w
        y2 = y + h

        face_image = frame[max(0, y1):min(height, y2), max(0, x1):min(width, x2)]
        identity = recognize_face(face_image, input_embeddings, model)

        if identity is not None:
            img = cv2.rectangle(frame, (x1, y1), (x2, y2), (255, 255, 255), 2)
            cv2.putText(img, str(identity), (x1 + 5, y1 - 5), font, 1, (255, 255, 255), 2)

    key = cv2.waitKey(100)
    cv2.imshow("Face Recognizer", img)

    if key == 27:  # exit on ESC
        break
vc.release()
cv2.destroyAllWindows()

cam = cv2.VideoCapture(0)

face_detector = myface_detector

count = 0
while(True):
ret, img = cam.read()
#gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_detector.detectMultiScale(img, 1.3, 5)
for (x,y,w,h) in faces:
x1 = x
y1 = y
x2 = x+w
y2 = y+h
cv2.rectangle(img, (x1,y1), (x2,y2), (255,255,255), 2)
count += 1
# Save the captured image into the datasets folder
cv2.imwrite("C:\Users\alhus\Desktop\cr7 photos" + str(count) + ".jpg", img[y1:y2,x1:x2])
cv2.imshow('image', img)
k = cv2.waitKey(200) & 0xff # Press 'ESC' for exiting video
if k == 27:
break
elif count >= 10: # Take 30 face sample and stop video
break
cam.release()
cv2.destroyAllWindows()

input_embeddings = create_input_image_embeddings()
recognize_faces_in_cam(input_embeddings)

`

Kernel keeps crashing

kernel keeps crashing while running the "# Lets run the face recognizer program :-)" section.
Screenshot 2019-07-26 at 14 09 09

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.