From 6a4df81e640cb490ee2e4189caff9fc316f7f3d0 Mon Sep 17 00:00:00 2001 From: Aatman Vaidya Date: Tue, 7 Jan 2025 13:35:11 +0530 Subject: [PATCH] feat: adding example notebooks --- examples/01_video_embeddings_tsne_plot.ipynb | 98 ++++++++++++++++++++ examples/01_video_embeddings_tsne_plot.yml | 9 ++ 2 files changed, 107 insertions(+) create mode 100644 examples/01_video_embeddings_tsne_plot.ipynb create mode 100644 examples/01_video_embeddings_tsne_plot.yml diff --git a/examples/01_video_embeddings_tsne_plot.ipynb b/examples/01_video_embeddings_tsne_plot.ipynb new file mode 100644 index 0000000..d622bbb --- /dev/null +++ b/examples/01_video_embeddings_tsne_plot.ipynb @@ -0,0 +1,98 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "880ce57b-d488-48f0-93ea-8c00d11c4cf7", + "metadata": {}, + "source": [ + "## Install Requried Dependencies" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "c1c2746d-00d1-4a32-8a2c-2ed703177460", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CPU times: user 36.2 ms, sys: 34.8 ms, total: 71 ms\n", + "Wall time: 5.96 s\n" + ] + } + ], + "source": [ + "%%time\n", + "%%capture\n", + "# install feluda and the requried operators\n", + "!uv pip install feluda\n", + "!uv pip install feluda-vid-vec-rep-clip\n", + "!uv pip install feluda-dimension-reduction\n", + "\n", + "# install other packages\n", + "!uv pip install huggingface-hub\n", + "!uv pip install matplotlib" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "41d7b1c6-157e-4c28-b362-2119779c7909", + "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'cv2'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[5], line 5\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mfeluda\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mmodels\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mmedia_factory\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m VideoFactory\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mhuggingface_hub\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m hf_hub_download\n\u001b[0;32m----> 5\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mcv2\u001b[39;00m\n\u001b[1;32m 6\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mtarfile\u001b[39;00m\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mmatplotlib\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mpyplot\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mplt\u001b[39;00m\n", + "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'cv2'" + ] + } + ], + "source": [ + "from feluda import Feluda\n", + "from feluda.models.media_factory import VideoFactory\n", + "\n", + "from huggingface_hub import hf_hub_download\n", + "import cv2\n", + "import tarfile\n", + "import matplotlib.pyplot as plt\n", + "from matplotlib.offsetbox import OffsetImage, AnnotationBbox" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "34312b7c-9879-4040-9f13-1f780a09d802", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/01_video_embeddings_tsne_plot.yml b/examples/01_video_embeddings_tsne_plot.yml new file mode 100644 index 0000000..f02e318 --- /dev/null +++ b/examples/01_video_embeddings_tsne_plot.yml @@ -0,0 +1,9 @@ +operators: + label: "Operators" + parameters: + - name: "Dimension Reduction" + type: "dimension_reduction" + parameters: { index_name: "video" } + - name: "Video Vector Representation" + type: "vid_vec_rep_clip" + parameters: { index_name: "video" }