From 9d50728bb59b25f31a533803a289bb289cbef2c6 Mon Sep 17 00:00:00 2001 From: raja <69231336+Rajasimhareddybolla@users.noreply.github.com> Date: Sat, 31 Aug 2024 17:30:41 +0530 Subject: [PATCH] Update video_classification.ipynb Align Colab notebook with official Hugging Face documentation for video classification - Identified missing code sections in `transformers_doc/en/tensorflow/video_classification.ipynb` that are correctly present in the official Hugging Face documentation. - Updated the Colab notebook to include these missing code snippets, ensuring consistency between the notebook and the [Hugging Face Video Classification Docs](https://huggingface.co/docs/transformers/en/tasks/video_classification). - This update fixes discrepancies that could lead to confusion or errors for users following the notebook in Colab, enhancing the reliability of the provided resources. - Verified the changes to ensure the notebook runs as expected with the corrected code. --- .../en/tensorflow/video_classification.ipynb | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/transformers_doc/en/tensorflow/video_classification.ipynb b/transformers_doc/en/tensorflow/video_classification.ipynb index 87697b86..97638100 100644 --- a/transformers_doc/en/tensorflow/video_classification.ipynb +++ b/transformers_doc/en/tensorflow/video_classification.ipynb @@ -149,6 +149,51 @@ " ...\n", "```\n", "\n", + "You can then count the number of total videos." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import pathlib\n", + "dataset_root_path = \"UCF101_subset\"\n", + "dataset_root_path = pathlib.Path(dataset_root_path)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "video_count_train = len(list(dataset_root_path.glob(\"train/*/*.avi\")))\n", + "video_count_val = len(list(dataset_root_path.glob(\"val/*/*.avi\")))\n", + "video_count_test = len(list(dataset_root_path.glob(\"test/*/*.avi\")))\n", + "video_total = video_count_train + video_count_val + video_count_test\n", + "print(f\"Total videos: {video_total}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "all_video_file_paths = (\n", + " list(dataset_root_path.glob(\"train/*/*.avi\"))\n", + " + list(dataset_root_path.glob(\"val/*/*.avi\"))\n", + " + list(dataset_root_path.glob(\"test/*/*.avi\"))\n", + " )\n", + "all_video_file_paths[:5]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "The (`sorted`) video paths appear like so:\n", "\n", "```bash\n", @@ -784,7 +829,11 @@ ] } ], - "metadata": {}, + "metadata": { + "language_info": { + "name": "python" + } + }, "nbformat": 4, "nbformat_minor": 4 }