"git@developer.sourcefind.cn:OpenDAS/megatron-lm.git" did not exist on "41c1af0ea24dfc26a0b87c33507d7b05a2d90cbc"
Commit b87c3899 authored by Mark Daoust's avatar Mark Daoust
Browse files

Fix: 'This doesn't really match the cell it precedes.'

parent b249129c
...@@ -199,46 +199,13 @@ ...@@ -199,46 +199,13 @@
"!unzip -o -q {sample_data_path} -d sample_images" "!unzip -o -q {sample_data_path} -d sample_images"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {
"id": "Kkg3SazB1edC"
},
"source": [
"Create a list of images to work on from the downloaded files."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "u0fqXQUzdZCu"
},
"outputs": [],
"source": [
"def embed_video_file(path: os.PathLike) -> display.HTML:\n",
" \"\"\"Embeds a file in the notebook as an html tag with a data-url.\"\"\"\n",
" path = pathlib.Path(path)\n",
" mime, unused_encoding = mimetypes.guess_type(str(path))\n",
" data = path.read_bytes()\n",
"\n",
" b64 = base64.b64encode(data).decode()\n",
" return display.HTML(\n",
" textwrap.dedent(\"\"\"\n",
" <video width=\"640\" height=\"480\" controls>\n",
" <source src=\"data:{mime};base64,{b64}\" type=\"{mime}\">\n",
" Your browser does not support the video tag.\n",
" </video>\n",
" \"\"\").format(mime=mime, b64=b64))\n"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "Ghf-4E5-ZiJn" "id": "Ghf-4E5-ZiJn"
}, },
"source": [ "source": [
"Write the images to a video file:" "Convert the images to a video file:"
] ]
}, },
{ {
...@@ -300,7 +267,31 @@ ...@@ -300,7 +267,31 @@
"id": "2ItoiHyYQGya" "id": "2ItoiHyYQGya"
}, },
"source": [ "source": [
"The images you downloaded are frames of a movie showing a top view of a coral reef with crown-of-thorns starfish. The movie looks like this:" "The images you downloaded are frames of a movie showing a top view of a coral reef with crown-of-thorns starfish. Use the `base64` data-URL trick to embed the video in this notebook:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "u0fqXQUzdZCu"
},
"outputs": [],
"source": [
"def embed_video_file(path: os.PathLike) -> display.HTML:\n",
" \"\"\"Embeds a file in the notebook as an html tag with a data-url.\"\"\"\n",
" path = pathlib.Path(path)\n",
" mime, unused_encoding = mimetypes.guess_type(str(path))\n",
" data = path.read_bytes()\n",
"\n",
" b64 = base64.b64encode(data).decode()\n",
" return display.HTML(\n",
" textwrap.dedent(\"\"\"\n",
" <video width=\"640\" height=\"480\" controls>\n",
" <source src=\"data:{mime};base64,{b64}\" type=\"{mime}\">\n",
" Your browser does not support the video tag.\n",
" </video>\n",
" \"\"\").format(mime=mime, b64=b64))\n"
] ]
}, },
{ {
...@@ -386,7 +377,7 @@ ...@@ -386,7 +377,7 @@
"id": "OvLuznhUa7uG" "id": "OvLuznhUa7uG"
}, },
"source": [ "source": [
"Here's one test image, how many COTS can you see:" "Here's one test image; how many COTS can you see?"
] ]
}, },
{ {
...@@ -683,7 +674,7 @@ ...@@ -683,7 +674,7 @@
"id": "B1q_n1xJLm60" "id": "B1q_n1xJLm60"
}, },
"source": [ "source": [
"That works well for one frame, but to count the number of COTS in a video you'll need to track the detections from frame to frame. The raw detection indices are not stable, they're just sorted by the detection score. Below both sets of detections are overlaid on the second image with the first frame's detections in white and the second frame's in orange, the indices are not aligned. The positions are shifted because of camera motion between teh two frames:" "That works well for one frame, but to count the number of COTS in a video you'll need to track the detections from frame to frame. The raw detection indices are not stable, they're just sorted by the detection score. Below both sets of detections are overlaid on the second image with the first frame's detections in white and the second frame's in orange, the indices are not aligned. The positions are shifted because of camera motion between the two frames:"
] ]
}, },
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment