Skip to content

Commit b60f8e9

Browse files
author
Zhi Zhou
committed
Address comments from Paul
1 parent e8a050c commit b60f8e9

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Azure AI Content Understanding is a new Generative AI-based [Azure AI service](h
1717
| [conversational_field_extraction.ipynb](notebooks/conversational_field_extraction.ipynb) | This sample shows you how to evaluate conversational audio data that has previously been transcribed with Content Understanding or Azure AI Speech in in an efficient way to optimize processing quality. This also allows you to re-analyze data in a cost-efficient way. This sample is based on the [field_extraction.ipynb](notebooks/field_extraction.ipynb) sample. |
1818
| [analyzer_training.ipynb](notebooks/analyzer_training.ipynb) | If you want to futher boost the performance for field extraction, we can do training when you provide few labeled samples to the API. Note: This feature is available to document scenario now. |
1919
| [management.ipynb](notebooks/management.ipynb) | This sample will demo how to create a minimal analyzer, list all the analyzers in your resource, and delete the analyzer you don't need. |
20-
| [build_person_directory.ipynb](notebooks/build_person_directory.ipynb) | This sample will demo how to enroll person’s faces from images and build a Person Directory. | |
20+
| [build_person_directory.ipynb](notebooks/build_person_directory.ipynb) | This sample will demo how to enroll people’s faces from images and build a Person Directory. | |
2121

2222
## Getting started
2323
### GitHub Codespaces

notebooks/build_person_directory.ipynb

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"source": [
1616
"## Objective\n",
1717
"\n",
18-
" This script builds a Person Directory by enrolling multiple faces for each person from a directory where each subfolder represents a different person. It creates a person for each subfolder and adds all face images within that subfolder to the created person.\n",
18+
" This notebook demonstrates how to build a Person Directory by enrolling multiple faces for each person. Each subfolder in a specified directory represents a different person. The script creates a person for each subfolder and adds all face images within that subfolder to the corresponding person\n",
1919
"\n",
2020
"| Enrollment | Searching |\n",
2121
"| :-: | :-: |\n",
@@ -28,7 +28,7 @@
2828
"metadata": {},
2929
"source": [
3030
"## Create Azure content understanding face client\n",
31-
">The [AzureContentUnderstandingFaceClient](../python/content_understanding_face_client.py) is utility Class which contain the functions to interact with the Content Understanding face server. Before Content Understanding SDK release, we can regard it as a lightweight SDK. Fill the constant **AZURE_AI_ENDPOINT**, **AZURE_AI_API_VERSION**, **AZURE_AI_API_KEY** with the information from your Azure AI Service."
31+
">The [AzureContentUnderstandingFaceClient](../python/content_understanding_face_client.py) is a utility class for interacting with the Content Understanding Face service. Before the official SDK is released, this acts as a lightweight SDK. Set the constants **AZURE_AI_ENDPOINT**, **AZURE_AI_API_VERSION**, and **AZURE_AI_API_KEY** with your Azure AI Service information."
3232
]
3333
},
3434
{
@@ -46,7 +46,7 @@
4646
"from azure.identity import DefaultAzureCredential, get_bearer_token_provider\n",
4747
"\n",
4848
"# import utility package from python samples root directory\n",
49-
"parent_dir = Path(Path.cwd()).parent\n",
49+
"parent_dir = Path.cwd().parent\n",
5050
"sys.path.append(str(parent_dir))\n",
5151
"from python.content_understanding_face_client import AzureContentUnderstandingFaceClient\n",
5252
"\n",
@@ -86,7 +86,7 @@
8686
"# Create a person directory\n",
8787
"person_directory_id = f\"person_directory_id_{uuid.uuid4().hex[:8]}\"\n",
8888
"client.create_person_directory(person_directory_id)\n",
89-
"print(f\"Created person directory with ID: {person_directory_id}\")\n",
89+
"logging.info(f\"Created person directory with ID: {person_directory_id}\")\n",
9090
"\n",
9191
"# Iterate through all subfolders in the folder_path\n",
9292
"for subfolder_name in os.listdir(folder_path):\n",
@@ -95,7 +95,7 @@
9595
" person_name = subfolder_name\n",
9696
" # Add a person for each subfolder\n",
9797
" person = client.add_person(person_directory_id, tags={\"name\": person_name})\n",
98-
" print(f\"Created person {person_name} with person_id: {person['personId']}\")\n",
98+
" logging.info(f\"Created person {person_name} with person_id: {person['personId']}\")\n",
9999
" if person:\n",
100100
" # Iterate through all images in the subfolder\n",
101101
" for filename in os.listdir(subfolder_path):\n",
@@ -106,11 +106,11 @@
106106
" # Add a face to the Person Directory and associate it to the added person\n",
107107
" face = client.add_face(person_directory_id, image_data, person['personId'])\n",
108108
" if face:\n",
109-
" print(f\"Added face from {filename} with face_id: {face['faceId']} to person_id: {person['personId']}\")\n",
109+
" logging.info(f\"Added face from {filename} with face_id: {face['faceId']} to person_id: {person['personId']}\")\n",
110110
" else:\n",
111-
" print(f\"Failed to add face from {filename} to person_id: {person['personId']}\")\n",
111+
" logging.warning(f\"Failed to add face from {filename} to person_id: {person['personId']}\")\n",
112112
"\n",
113-
"print(\"Done\")"
113+
"logging.info(\"Done\")"
114114
]
115115
},
116116
{
@@ -119,7 +119,7 @@
119119
"metadata": {},
120120
"source": [
121121
"### Identifying person\n",
122-
"Detect multiple faces in an image and identify each one by matching it against enrolled persons in a Person Directory."
122+
"Detect multiple faces in an image and identify each one by matching it against enrolled persons in the Person Directory."
123123
]
124124
},
125125
{
@@ -139,9 +139,9 @@
139139
" if identified_persons.get(\"personCandidates\"):\n",
140140
" person = identified_persons[\"personCandidates\"][0]\n",
141141
" name = person.get(\"tags\", {}).get(\"name\", \"Unknown\")\n",
142-
" print(f\"Detected person: {name} with confidence: {person.get('confidence', 0)} at bounding box: {face['boundingBox']}\")\n",
142+
" logging.info(f\"Detected person: {name} with confidence: {person.get('confidence', 0)} at bounding box: {face['boundingBox']}\")\n",
143143
"\n",
144-
"print(\"Done\")"
144+
"logging.info(\"Done\")"
145145
]
146146
},
147147
{
@@ -150,7 +150,7 @@
150150
"metadata": {},
151151
"source": [
152152
"### Adding and associating a new face\n",
153-
"You can add an additional face to a Person Directory and associate it with an already enrolled person."
153+
"You can add a new face to the Person Directory and associate it with an existing person."
154154
]
155155
},
156156
{
@@ -168,9 +168,9 @@
168168
"# Add the new face to the person directory and associate it with the existing person\n",
169169
"face = client.add_face(person_directory_id, image_data, existing_person_id)\n",
170170
"if face:\n",
171-
" print(f\"Added face from {new_face_image_path} with face_id: {face['faceId']} to person_id: {existing_person_id}\")\n",
171+
" logging.info(f\"Added face from {new_face_image_path} with face_id: {face['faceId']} to person_id: {existing_person_id}\")\n",
172172
"else:\n",
173-
" print(f\"Failed to add face from {new_face_image_path} to person_id: {existing_person_id}\")"
173+
" logging.warning(f\"Failed to add face from {new_face_image_path} to person_id: {existing_person_id}\")"
174174
]
175175
},
176176
{
@@ -180,7 +180,7 @@
180180
"source": [
181181
"### Associating a list of already enrolled faces\n",
182182
"\n",
183-
"You can associate a list of already enrolled faces in the Person Directory with their respective persons. This can be useful when you have existing face IDs and want to associate them to specific persons in the directory."
183+
"You can associate a list of already enrolled faces in the Person Directory with their respective persons. This is useful if you have existing face IDs to link to specific persons."
184184
]
185185
},
186186
{
@@ -217,14 +217,14 @@
217217
"\n",
218218
"# Remove the association of the existing face ID from the person\n",
219219
"client.update_face(person_directory_id, existing_face_id, person_id=\"\") # The person_id is set to \"\" to remove the association\n",
220-
"print(f\"Removed association of face_id: {existing_face_id} from the existing person_id\")\n",
221-
"print(client.get_face(person_directory_id, existing_face_id)) # This will return the face information without the person association\n",
220+
"logging.info(f\"Removed association of face_id: {existing_face_id} from the existing person_id\")\n",
221+
"logging.info(client.get_face(person_directory_id, existing_face_id)) # This will return the face information without the person association\n",
222222
"\n",
223223
"# Associate the existing face ID with a person\n",
224224
"existing_person_id = \"existing_person_id\" # The unique ID of the person to be associated with the face.\n",
225225
"client.update_face(person_directory_id, existing_face_id, person_id=existing_person_id)\n",
226-
"print(f\"Associated face_id: {existing_face_id} with person_id: {existing_person_id}\")\n",
227-
"print(client.get_face(person_directory_id, existing_face_id)) # This will return the face information with the new person association"
226+
"logging.info(f\"Associated face_id: {existing_face_id} with person_id: {existing_person_id}\")\n",
227+
"logging.info(client.get_face(person_directory_id, existing_face_id)) # This will return the face information with the new person association"
228228
]
229229
},
230230
{
@@ -233,7 +233,7 @@
233233
"metadata": {},
234234
"source": [
235235
"### Updating metadata (tags and descriptions)\n",
236-
"You can add or update tags for individual persons, and both descriptions and tags for the overall Person Directory. These metadata fields help you better organize, filter, and manage your directory."
236+
"You can add or update tags for individual persons, and both descriptions and tags for the Person Directory. These metadata fields help organize, filter, and manage your directory."
237237
]
238238
},
239239
{
@@ -252,8 +252,8 @@
252252
" description=person_directory_description,\n",
253253
" tags=person_directory_tags\n",
254254
")\n",
255-
"print(f\"Updated Person Directory with description: '{person_directory_description}' and tags: {person_directory_tags}\")\n",
256-
"print(client.get_person_directory(person_directory_id)) # This will return the updated person directory information\n",
255+
"logging.info(f\"Updated Person Directory with description: '{person_directory_description}' and tags: {person_directory_tags}\")\n",
256+
"logging.info(client.get_person_directory(person_directory_id)) # This will return the updated person directory information\n",
257257
"\n",
258258
"# Update the tags for an individual person\n",
259259
"existing_person_id = \"existing_person_id\" # The unique ID of the person to update.\n",
@@ -264,8 +264,8 @@
264264
" existing_person_id,\n",
265265
" tags=person_tags\n",
266266
")\n",
267-
"print(f\"Updated person with person_id: {existing_person_id} with tags: {person_tags}\")\n",
268-
"print(client.get_person(person_directory_id, existing_person_id)) # This will return the updated person information"
267+
"logging.info(f\"Updated person with person_id: {existing_person_id} with tags: {person_tags}\")\n",
268+
"logging.info(client.get_person(person_directory_id, existing_person_id)) # This will return the updated person information"
269269
]
270270
},
271271
{
@@ -287,7 +287,7 @@
287287
"existing_face_id = \"existing_face_id\" # The unique ID of the face to delete.\n",
288288
"\n",
289289
"client.delete_face(person_directory_id, existing_face_id)\n",
290-
"print(f\"Deleted face with face_id: {existing_face_id}\")"
290+
"logging.info(f\"Deleted face with face_id: {existing_face_id}\")"
291291
]
292292
},
293293
{
@@ -310,7 +310,7 @@
310310
"existing_person_id = \"existing_person_id\" # The unique ID of the person to delete.\n",
311311
"\n",
312312
"client.delete_person(person_directory_id, existing_person_id)\n",
313-
"print(f\"Deleted person with person_id: {existing_person_id}\")"
313+
"logging.info(f\"Deleted person with person_id: {existing_person_id}\")"
314314
]
315315
},
316316
{
@@ -338,12 +338,12 @@
338338
"\n",
339339
"# Delete each face associated with the person\n",
340340
"for face_id in face_ids:\n",
341-
" print(f\"Deleting face with face_id: {face_id} from person_id: {existing_person_id}\")\n",
341+
" logging.info(f\"Deleting face with face_id: {face_id} from person_id: {existing_person_id}\")\n",
342342
" client.delete_face(person_directory_id, face_id)\n",
343343
"\n",
344344
"# Delete the person after deleting all associated faces\n",
345345
"client.delete_person(person_directory_id, existing_person_id)\n",
346-
"print(f\"Deleted person with person_id: {existing_person_id} and all associated faces.\")"
346+
"logging.info(f\"Deleted person with person_id: {existing_person_id} and all associated faces.\")"
347347
]
348348
}
349349
],

0 commit comments

Comments
 (0)