Skip to content

Commit

Permalink
Merge pull request #207 from junjiejiangjjj/video_ret
Browse files Browse the repository at this point in the history
Update new interface
  • Loading branch information
shiyu22 authored Jun 21, 2023
2 parents f3c11a9 + 3e61b1b commit 9a788d0
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions video/text_video_retrieval/1_text_video_retrieval_engine.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "868d7f57",
"metadata": {},
Expand All @@ -25,6 +26,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "157044a8",
"metadata": {},
Expand All @@ -50,22 +52,13 @@
"execution_count": 1,
"id": "4bc9560b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\r\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.0\u001b[0m\r\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\r\n"
]
}
],
"outputs": [],
"source": [
"! python -m pip install -q pymilvus towhee towhee.models pillow ipython gradio"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "5891a4e6",
"metadata": {},
Expand Down Expand Up @@ -98,8 +91,8 @@
"text": [
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
" Dload Upload Total Spent Left Speed\n",
" 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\n",
"100 210M 100 210M 0 0 4588k 0 0:00:46 0:00:46 --:--:-- 5015k77k 0 0:01:00 0:00:10 0:00:50 4666k\n"
" 0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0\n",
"100 210M 100 210M 0 0 1961k 0 0:01:49 0:01:49 --:--:-- 2072k 1937k 0 0:01:51 0:01:29 0:00:22 1913k\n"
]
}
],
Expand Down Expand Up @@ -229,6 +222,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "ae4911f0",
"metadata": {},
Expand All @@ -247,7 +241,7 @@
"source": [
"from IPython import display\n",
"from pathlib import Path\n",
"import towhee\n",
"from towhee import pipe, ops\n",
"from PIL import Image\n",
"\n",
"def display_gif(video_path_list, text_list):\n",
Expand All @@ -259,11 +253,12 @@
"\n",
" \n",
"def convert_video2gif(video_path, output_gif_path, num_samples=16):\n",
" frames = (\n",
" towhee.glob(video_path)\n",
" .video_decode.ffmpeg(sample_type='uniform_temporal_subsample', args={'num_samples': num_samples})\n",
" .to_list()[0]\n",
" p = (\n",
" pipe.input('video_path')\n",
" .map('video_path', 'video_frames', ops.video_decode.ffmpeg(sample_type='uniform_temporal_subsample', args={'num_samples': num_samples}))\n",
" .output('video_frames')\n",
" )\n",
" frames = p(video_path).to_list()[0][0]\n",
" imgs = [Image.fromarray(frame) for frame in frames]\n",
" imgs[0].save(fp=output_gif_path, format='GIF', append_images=imgs[1:], save_all=True, loop=0)\n",
"\n",
Expand All @@ -280,6 +275,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "7bcdea96",
"metadata": {},
Expand Down Expand Up @@ -319,6 +315,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "c57038b4",
"metadata": {},
Expand Down Expand Up @@ -371,6 +368,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "7c72d0e8",
"metadata": {},
Expand Down Expand Up @@ -485,6 +483,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "6bb5e044",
"metadata": {},
Expand Down Expand Up @@ -569,6 +568,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "bf7722c7",
"metadata": {},
Expand Down Expand Up @@ -635,6 +635,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "1b886b88",
"metadata": {},
Expand All @@ -643,6 +644,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "8a1e2a48",
"metadata": {},
Expand Down Expand Up @@ -759,7 +761,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 9a788d0

Please sign in to comment.