
My name is Jasper Camber Holton. I write, code, make music, and I am the developer of Uglek.com.
Has 347 posts, follows 17 users and is followed by 12 users.
Last seen at June 29, 2022 10:54




I appreciate your interest in my site and I'm looking forward to having you here. I've done more work to keep the site secure and this should make the site easier to use. I'm hoping people will want to log in with their faces, and create new accounts with their faces. Using proximity detection, I can make sure the users face is close to the camera, and I have added a spinner to the login form.

@AussieinthePNW, likes this,

Log in to Uglek or create an account with your face! It even works in the dark. Here's my face to go with the new feature. Visit Uglek.com/face/login to log in with your face or create a new account with your face. Try it out now!


How to identify and recognize faces using python with no APIs I use the below code to implement a login with face function on Uglek. The code works by assigning a user a face ID when they upload a face to their profile or go to log in, and then retrieving their account by image using the face ID. Here is the code
# face/face.py
from django.contrib.auth.models import User
import uuid
from .models import Face
import face_recognition
NUM_FACES = 9
def get_face_id(image_path):
image = face_recognition.load_image_file(image_path)
face_locations = face_recognition.face_locations(image)
if len(face_locations) > 1 or len(face_locations) < 1:
return False
for user in User.objects.filter(profile__enable_facial_recognition=True):
known_image = face_recognition.load_image_file(user.profile.face.path)
unknown_image = image
user_encoding = face_recognition.face_encodings(known_image)[0]
user_encodings = list()
user_encodings.append(user_encoding)
user_faces = Face.objects.filter(user=user).order_by('-timestamp')
for face in user_faces:
if open(face.image.path,"rb").read() == open(image_path,"rb").read():
return False
if user_faces.count() > NUM_FACES:
user_faces = user_faces[:NUM_FACES]
for face in user_faces:
image = face_recognition.load_image_file(face.image.path)
image_encoding = face_recognition.face_encodings(image)[0]
user_encodings.append(image_encoding)
unknown_encoding = face_recognition.face_encodings(unknown_image)[0]
results = face_recognition.compare_faces(user_encodings, unknown_encoding)
if results[0]:
return user.profile.uuid
return str(uuid.uuid4())

An Epic Orchestral Synthesizer Track This is an awesome song I wrote earlier this month. I wrote it to share with @AussieinthePNW on my birthday but I didn't get a chance to post it then. Finally remembered to do so, as I am posting some of my other songs. This is an awesome listen!
@AussieinthePNW, likes this,

How to Identify Unique Faces with the Microsoft Azure Face API Using the Microsoft Azure Face API, you can assign unique faces a UUID and identify them for use in login, verification, or any other purpose. The following code accepts an image of a single face and returns a unique UUID representing that face. This has a huge application potential in internet security and could make some sites and businesses much more secure, by uniquely attributing faces to profiles within the apps or security solutions. Using the face API with Microsoft Azure is free for basic use, and isn't expensive otherwise. To install python modules for this code, run $ pip install --upgrade azure-cognitiveservices-vision-face $ pip install --upgrade Pillow The code is as follows.
# face/face.py
import asyncio
import io
import glob
import os
import sys
import time
import uuid
import requests
from urllib.parse import urlparse
from io import BytesIO
from PIL import Image, ImageDraw
from azure.cognitiveservices.vision.face import FaceClient
from msrest.authentication import CognitiveServicesCredentials
from azure.cognitiveservices.vision.face.models import TrainingStatusType, Person, QualityForRecognition
import json
# This key will serve all examples in this document.
KEY = "000000000000000000000000000000"
# This endpoint will be used in all examples in this quickstart.
ENDPOINT = "https://endpoint.api.cognitive.microsoft.com/"
PERSON_GROUP_ID = str("group") # assign a random ID (or name it anything)
def get_face_id(single_face_image_url):
# Create an authenticated FaceClient.
face_client = FaceClient(ENDPOINT, CognitiveServicesCredentials(KEY))
# Detect a face in an image that contains a single face
single_image_name = os.path.basename(single_face_image_url)
# We use detection model 3 to get better performance.
face_ids = []
# We use detection model 3 to get better performance, recognition model 4 to support quality for recognition attribute.
faces = face_client.face.detect_with_url(single_face_image_url, detection_model='detection_03') #, recognition_model='recognition_04', return_face_attributes=['qualityForRecognition'])
# Remove this line after initial call with first face (or you will get an error on the next call)
face_client.person_group.create(person_group_id=PERSON_GROUP_ID, name=PERSON_GROUP_ID)
for face in faces: # Add faces in the photo to a list
face_ids.append(face.face_id)
if len(faces) > 1: # Return if there are too many faces
return False
results = None
try:
results = face_client.face.identify(face_ids, PERSON_GROUP_ID) # Identify the face
except:
results = None
if not results: # Add the face if they are not identified
p = face_client.person_group_person.create(PERSON_GROUP_ID, uuid.uuid4()) # Identify them with a UUID
face_client.person_group_person.add_face_from_url(PERSON_GROUP_ID, p.person_id, single_face_image_url)
face_client.person_group.train(PERSON_GROUP_ID) # Training
while (True):
training_status = face_client.person_group.get_training_status(PERSON_GROUP_ID)
print("Training status: {}.".format(training_status.status))
print()
if (training_status.status is TrainingStatusType.succeeded):
break
elif (training_status.status is TrainingStatusType.failed):
sys.exit('Training the person group has failed.')
time.sleep(5)
results = face_client.face.identify(face_ids, PERSON_GROUP_ID)
if results and len(results) > 0: # Load their UUID
res = json.loads(str(results[0].candidates[0]).replace('\'',"\""))['person_id']
print(res)
return res # Return their UUID
return False # Or return false to indicate that no face was recognized.
f = 'uglek.com/media/face/1b195bf5-8150-4f84-931d-ef0f2a464d06.png'
print(get_face_id(f)) # Identify a face from this image

This is my new profile picture, of my face in the light. Hope you enjoy!

@AussieinthePNW, likes this,
© Uglek, 2022