Skip to content

Commit 28d914c

Browse files
lanazhangLana Zhang
and
Lana Zhang
authored
Notebook metadata update and video lab improvement (#18)
* fix notebook metadata and the other RI feedbacks * Update translate lab step description * fix notebook metadata Co-authored-by: Lana Zhang <[email protected]>
1 parent 2e15a05 commit 28d914c

9 files changed

+35
-34
lines changed

content-moderation/01-image-moderation/01-content-moderation-image.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
"metadata": {
231231
"instance_type": "ml.t3.medium",
232232
"kernelspec": {
233-
"display_name": "Python 3.10.2 64-bit",
233+
"display_name": "Python 3 (Data Science)",
234234
"language": "python",
235235
"name": "python3"
236236
},
@@ -244,7 +244,7 @@
244244
"name": "python",
245245
"nbconvert_exporter": "python",
246246
"pygments_lexer": "ipython3",
247-
"version": "3.10.2"
247+
"version": "3.7.10"
248248
},
249249
"vscode": {
250250
"interpreter": {

content-moderation/01-image-moderation/02-content-moderation-image-with-human-in-the-loop.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@
575575
"metadata": {
576576
"instance_type": "ml.t3.medium",
577577
"kernelspec": {
578-
"display_name": "Python 3.10.2 64-bit",
578+
"display_name": "Python 3 (Data Science)",
579579
"language": "python",
580580
"name": "python3"
581581
},
@@ -589,7 +589,7 @@
589589
"name": "python",
590590
"nbconvert_exporter": "python",
591591
"pygments_lexer": "ipython3",
592-
"version": "3.10.2"
592+
"version": "3.7.10"
593593
},
594594
"vscode": {
595595
"interpreter": {

content-moderation/02-video-moderation/01-content-moderation-video.ipynb

+12-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"\n",
1616
"Amazon Rekognition Video inappropriate or offensive content detection in stored videos is an asynchronous operation. To start detecting inappropriate or offensive content, call [StartContentModeration](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartContentModeration.html). Amazon Rekognition Video publishes the completion status of the video analysis to an Amazon Simple Notification Service topic. If the video analysis is successful, call [GetContentModeration](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetContentModeration.html) to get the analysis results. For more information about starting video analysis and getting the results, see [Calling Amazon Rekognition Video operations](https://docs.aws.amazon.com/rekognition/latest/dg/api-video.html). \n",
1717
"\n",
18-
"This tutorial will show you how to use Amazon Rekognition Moderation API to moderate stored videos, how to extract text from a video using Amazon Rekognition for Text Moderation, and how to transcribe the audio of the video into text for Text Moderation."
18+
"This tutorial will show you how to use Amazon Rekognition Moderation API to moderate stored videos, how to extract text from a video using Amazon Rekognition for Text Moderation, and how to transcribe the audio of the video into text for Text Moderation. This lab will not cover the text moderation logic. You can refer to labs in the **04-text-moderation** module for more examples."
1919
]
2020
},
2121
{
@@ -26,8 +26,8 @@
2626
"\n",
2727
"- [Step 1: Setup Notebook](#step1)\n",
2828
"- [Step 2: Moderate video using Rekognition video moderation API](#step2)\n",
29-
"- [Step 3: Moderate text in video](#step3)\n",
30-
"- [Step 4: Moderate audio in video](#step4)\n",
29+
"- [Step 3: Detect text in video](#step3)\n",
30+
"- [Step 4: Transcribe audio in video](#step4)\n",
3131
"- [Step 5: Clean up](#step5)"
3232
]
3333
},
@@ -79,7 +79,6 @@
7979
"\n",
8080
"s3=boto3.client('s3', region_name=region)\n",
8181
"rekognition=boto3.client('rekognition', region_name=region)\n",
82-
"sagemaker = boto3.client('sagemaker', region_name=region)\n",
8382
"comprehend = boto3.client('comprehend', region_name=region)\n",
8483
"transcribe=boto3.client('transcribe', region_name=region)"
8584
]
@@ -176,7 +175,7 @@
176175
"for label in getContentModeration[\"ModerationLabels\"]:\n",
177176
" if len(label[\"ModerationLabel\"][\"ParentName\"]) > 0:\n",
178177
" label_html += f'''<a onclick=\"document.getElementById('cccvid1').currentTime={round(label['Timestamp']/1000)}\">[{label['Timestamp']} ms]: \n",
179-
" {label['ModerationLabel']['Name']}, confidence: {round(label['ModerationLabel']['Confidence'])}</a><br/>\n",
178+
" {label['ModerationLabel']['Name']}, confidence: {round(label['ModerationLabel']['Confidence'],2)}%</a><br/>\n",
180179
" '''\n",
181180
"display(HTML(video_tag))\n",
182181
"display(HTML(label_html))"
@@ -186,7 +185,7 @@
186185
"cell_type": "markdown",
187186
"metadata": {},
188187
"source": [
189-
"# Step 3: Moderate text in video <a id=\"step3\"></a>"
188+
"# Step 3: Extract text in video <a id=\"step3\"></a>"
190189
]
191190
},
192191
{
@@ -247,7 +246,7 @@
247246
"for txt in getTextDetection[\"TextDetections\"]:\n",
248247
" if txt[\"TextDetection\"][\"Type\"] == 'LINE':\n",
249248
" text_html += f'''<a onclick=\"document.getElementById('cccvid2').currentTime={round(txt['Timestamp']/1000)}\">[{txt['Timestamp']} ms]: \n",
250-
" {txt[\"TextDetection\"][\"DetectedText\"]}, confidence: {round(txt[\"TextDetection\"][\"Confidence\"],2)}</a><br/>\n",
249+
" {txt[\"TextDetection\"][\"DetectedText\"]}, confidence: {round(txt[\"TextDetection\"][\"Confidence\"],2)}%</a><br/>\n",
251250
" '''\n",
252251
"display(HTML(video_tag))\n",
253252
"display(HTML(text_html))"
@@ -264,7 +263,7 @@
264263
"cell_type": "markdown",
265264
"metadata": {},
266265
"source": [
267-
"# Step 4: Moderate audio in video <a id=\"step4\"></a>\n",
266+
"# Step 4: Transcribe audio in video <a id=\"step4\"></a>\n",
268267
"\n",
269268
"We have moderated the video and extracted text from the video using Rekognition. Now, we will transcribe the audio to text using Amazon Transcribe.\n",
270269
"\n",
@@ -277,7 +276,8 @@
277276
"metadata": {},
278277
"outputs": [],
279278
"source": [
280-
"job_name = 'video_moderation_job1'\n",
279+
"import uuid\n",
280+
"job_name = f'video_moderation_{str(uuid.uuid1())[0:4]}'\n",
281281
"\n",
282282
"transcribe.start_transcription_job(\n",
283283
" TranscriptionJobName = job_name,\n",
@@ -296,7 +296,7 @@
296296
" time.sleep(5)\n",
297297
" print('.', end='')\n",
298298
"\n",
299-
" getTranscription = rekognition.get_transcription_job(TranscriptionJobName = job_name)\n",
299+
" getTranscription = transcribe.get_transcription_job(TranscriptionJobName = job_name)\n",
300300
"\n",
301301
"display(getTranscription['TranscriptionJob']['TranscriptionJobStatus'])"
302302
]
@@ -361,7 +361,7 @@
361361
"metadata": {
362362
"instance_type": "ml.t3.medium",
363363
"kernelspec": {
364-
"display_name": "Python 3.10.2 64-bit",
364+
"display_name": "Python 3 (Data Science)",
365365
"language": "python",
366366
"name": "python3"
367367
},
@@ -375,7 +375,7 @@
375375
"name": "python",
376376
"nbconvert_exporter": "python",
377377
"pygments_lexer": "ipython3",
378-
"version": "3.10.2"
378+
"version": "3.7.10"
379379
},
380380
"vscode": {
381381
"interpreter": {

content-moderation/02-video-moderation/02-content-moderation-video-with-human-in-the-loop.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@
594594
"metadata": {
595595
"instance_type": "ml.t3.medium",
596596
"kernelspec": {
597-
"display_name": "Python 3.10.2 64-bit",
597+
"display_name": "Python 3 (Data Science)",
598598
"language": "python",
599599
"name": "python3"
600600
},
@@ -608,7 +608,7 @@
608608
"name": "python",
609609
"nbconvert_exporter": "python",
610610
"pygments_lexer": "ipython3",
611-
"version": "3.10.2"
611+
"version": "3.7.10"
612612
},
613613
"vscode": {
614614
"interpreter": {

content-moderation/03-audio-moderation/01-content-moderation-audio-transcribe-with-custom-vocabulary.ipynb

+6-4
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@
109109
"metadata": {},
110110
"outputs": [],
111111
"source": [
112-
"job_name = 'audio_moderation_job1'\n",
112+
"import uuid\n",
113+
"job_name = f'audio_moderation_{str(uuid.uuid1())[0:4]}'\n",
113114
"\n",
114115
"transcribe_client.start_transcription_job(\n",
115116
" TranscriptionJobName = job_name,\n",
@@ -221,7 +222,8 @@
221222
"#In this case we are running the transcribe job with option to \"mask\" the words. You can also run the job with \"remove\" or \"tag\". \n",
222223
"#In each case, give a new job_name and change the VocabularyFilterMethod to the desired option\n",
223224
"\n",
224-
"job_name = \"transcription_with_audio_moderation_mask1\"\n",
225+
"job_name = f'transcription_with_audio_moderation_mask_{str(uuid.uuid1())[0:4]}'\n",
226+
"\n",
225227
"transcribe_client.start_transcription_job(\n",
226228
" TranscriptionJobName = job_name,\n",
227229
" Media = {\n",
@@ -311,7 +313,7 @@
311313
"metadata": {
312314
"instance_type": "ml.t3.medium",
313315
"kernelspec": {
314-
"display_name": "Python 3.10.2 64-bit",
316+
"display_name": "Python 3 (Data Science)",
315317
"language": "python",
316318
"name": "python3"
317319
},
@@ -325,7 +327,7 @@
325327
"name": "python",
326328
"nbconvert_exporter": "python",
327329
"pygments_lexer": "ipython3",
328-
"version": "3.10.2"
330+
"version": "3.7.10"
329331
},
330332
"vscode": {
331333
"interpreter": {

content-moderation/04-text-moderation/01-content-moderation-text-pii-sentiment.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@
366366
"metadata": {
367367
"instance_type": "ml.m5.large",
368368
"kernelspec": {
369-
"display_name": "Python 3.10.2 64-bit",
369+
"display_name": "Python 3 (Data Science)",
370370
"language": "python",
371371
"name": "python3"
372372
},
@@ -380,7 +380,7 @@
380380
"name": "python",
381381
"nbconvert_exporter": "python",
382382
"pygments_lexer": "ipython3",
383-
"version": "3.10.2"
383+
"version": "3.7.10"
384384
},
385385
"vscode": {
386386
"interpreter": {

content-moderation/04-text-moderation/02-content-moderation-text-toxic-classification.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@
450450
"metadata": {
451451
"instance_type": "ml.t3.large",
452452
"kernelspec": {
453-
"display_name": "Python 3.10.2 64-bit",
453+
"display_name": "Python 3 (Data Science)",
454454
"language": "python",
455455
"name": "python3"
456456
},
@@ -464,7 +464,7 @@
464464
"name": "python",
465465
"nbconvert_exporter": "python",
466466
"pygments_lexer": "ipython3",
467-
"version": "3.10.2"
467+
"version": "3.7.10"
468468
},
469469
"vscode": {
470470
"interpreter": {

content-moderation/05-translate-moderation/01-content_moderation-translate-profanity-masking.ipynb

+7-8
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
"![Translate-text-profanity](../images/TranslateModeration.png)\n",
1717
"\n",
1818
"- [Step 1: Setup Notebook](#step1)\n",
19-
"- [Step 2: Setup Variables and import packages](#step2)\n",
20-
"- [Step 3: Setup input text file & Run Translate without profanity masking](#step3)\n",
21-
"- [Step 4: Use Profanity mask Settings with Translate](#step4)\n"
19+
"- [Step 2: Setup input text file & Run Translate without profanity masking](#step2)\n",
20+
"- [Step 3: Use Profanity mask Settings with Translate](#step3)\n"
2221
]
2322
},
2423
{
@@ -43,7 +42,7 @@
4342
"cell_type": "markdown",
4443
"metadata": {},
4544
"source": [
46-
"# Step 2: Setup Variables and import packages <a id=\"step2\"></a>"
45+
"Setup Variables and import packages"
4746
]
4847
},
4948
{
@@ -78,7 +77,7 @@
7877
"cell_type": "markdown",
7978
"metadata": {},
8079
"source": [
81-
"# Step 3: Setup input text file & Run Translate without profanity masking <a id=\"step3\"></a>\n",
80+
"# Step 2: Setup input text file & Run Translate without profanity masking <a id=\"step2\"></a>\n",
8281
"You can open translate-input-text.txt file in datasets directory and see the input text. Run the below cell to upload a sample text file to the default S3 bucket for Translate to access."
8382
]
8483
},
@@ -137,7 +136,7 @@
137136
"cell_type": "markdown",
138137
"metadata": {},
139138
"source": [
140-
"# Step 4: Use Profanity mask Settings with Translate <a id=\"step4\"></a>\n",
139+
"# Step 3: Use Profanity mask Settings with Translate <a id=\"step3\"></a>\n",
141140
"\n",
142141
"In the below cell, we call the same Translate `TranslateText` API by passing an additional profanity parameter as part of `Settings`. This will enable the profanity setting and Amazon Translate will mask profane words and phrases in your translation output.\n",
143142
"\n",
@@ -191,7 +190,7 @@
191190
"metadata": {
192191
"instance_type": "ml.t3.medium",
193192
"kernelspec": {
194-
"display_name": "Python 3.10.2 64-bit",
193+
"display_name": "Python 3 (Data Science)",
195194
"language": "python",
196195
"name": "python3"
197196
},
@@ -205,7 +204,7 @@
205204
"name": "python",
206205
"nbconvert_exporter": "python",
207206
"pygments_lexer": "ipython3",
208-
"version": "3.10.2"
207+
"version": "3.7.10"
209208
},
210209
"vscode": {
211210
"interpreter": {
Loading

0 commit comments

Comments
 (0)