Skip to content

Commit

Permalink
Minor updates to S3D MIL-NCE colab
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 316747124
  • Loading branch information
TensorFlow Hub Authors authored and kempy committed Jun 16, 2020
1 parent e3adc8e commit b19e1ff
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions examples/colab/text_to_video_retrieval_with_s3d_milnce.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"id": "z2_BHI6XdJ30"
},
"source": [
"# Text-to-Video retrieval with S3D MIL-NCE using the TF-Hub module"
"# Text-to-Video retrieval with S3D MIL-NCE"
]
},
{
Expand Down Expand Up @@ -89,7 +89,11 @@
"id": "ZxwaK-jf7qkW"
},
"source": [
"## Import TF-Hub module"
"## Import TF-Hub model\n",
"\n",
"This tutorial demonstrates how to use the [S3D MIL-NCE model](https://tfhub.dev/deepmind/mil-nce/s3d/1) from TensorFlow Hub to do **text-to-video retrieval** to find the most similar videos for a given text query.\n",
"\n",
"The model has 2 signatures, one for generating *video embeddings* and one for generating *text embeddings*. We will use these embedding to find the nearest neighbors in the embedding space."
]
},
{
Expand Down Expand Up @@ -186,8 +190,7 @@
" html += '\u003cimg src=\"{}\" height=\"224\"\u003e'.format(url)\n",
" html += '\u003c/td\u003e'\n",
" html += '\u003c/tr\u003e\u003c/table\u003e'\n",
" return html\n",
"\n"
" return html\n"
]
},
{
Expand All @@ -200,7 +203,7 @@
},
"outputs": [],
"source": [
"# @title Load example images and define text queries { display-mode: \"form\" }\n",
"# @title Load example videos and define text queries { display-mode: \"form\" }\n",
"\n",
"video_1_url = 'https://upload.wikimedia.org/wikipedia/commons/b/b0/YosriAirTerjun.gif' # @param {type:\"string\"}\n",
"video_2_url = 'https://upload.wikimedia.org/wikipedia/commons/e/e6/Guitar_solo_gif.gif' # @param {type:\"string\"}\n",
Expand Down Expand Up @@ -245,7 +248,7 @@
"# Prepare text input.\n",
"words_np = np.array(all_queries_video)\n",
"\n",
"# Run the graph.\n",
"# Generate the video and text embeddings.\n",
"video_embd, text_embd = generate_embeddings(hub_model, videos_np, words_np)\n",
"\n",
"# Scores between video and text is computed by dot products.\n",
Expand Down Expand Up @@ -274,7 +277,7 @@
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "text_to_video_retrieval_with_s3d_milnce.ipynb",
"name": "Text-to-Video retrieval with S3D MIL-NCE",
"private_outputs": true,
"provenance": [],
"toc_visible": true
Expand Down

0 comments on commit b19e1ff

Please sign in to comment.