


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,

How to Generate a String from a Number in Python I use the following code to generate a string from a number under 1000. It is using simple arrays and if statements to generate a compound number as a string.
import math
n = ['one','two','three','four','five', 'six', 'seven', 'eight', 'nine', 'ten']
tn = ['eleven','twelve','thir','four','fif','six','seven','eigh','nine']
nn = ['ten','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']
def number_to_string(num):
if not isinstance(num, int):
num = int(num) if num != '' else 'done'
if num == 'done':
return ''
if num == 0:
return ''
if num < 11:
return n[num-1]
if num < 20:
if num < 13:
return tn[num-11]
return tn[num-11] + 'teen'
if num < 100:
extra = '-'+n[num%10-1]
if num%10 == 0:
extra = ''
return nn[math.floor(num/10)-1]+extra
if num < 1000:
extra = '-'+n[num%10-1]
if num%10 == 0:
extra = ''
snum = str(num)
return n[math.floor(num/100)-1]+'-hundred'+ ('-' if number_to_string(int(snum[1:])) != '' else '') + number_to_string(int(snum[1:]))
if num < 10000:
snum = str(num)
return number_to_string(int(snum[:1])) + '-thousand' + ('-' if number_to_string(int(snum[1:])) != '' else '') +number_to_string(int(snum[1:]))
if num < 100000:
snum = str(num)
return number_to_string(int(snum[:2])) + '-thousand' + ('-' if number_to_string(int(snum[2:])) != '' else '') + number_to_string(int(snum[2:]))
if num < 1000000:
snum = str(num)
return number_to_string(snum[:len(snum) - 3]) + '-thousand' + ('-' if number_to_string(snum[len(snum)-3:]) != '' else '') + number_to_string(snum[len(snum)-3:])
if num < 1000000000:
snum = str(num)
return number_to_string(snum[:len(snum) - 6]) + '-million' + ('-' if number_to_string(snum[len(snum)-6:]) != '' else '') + number_to_string(snum[len(snum)-6:])
return 'number too large to compute!'
#for x in range(1,100000):
# print(number_to_string(x))
print(number_to_string(999999999))
© Uglek, 2022