Auto download sample video if not found locally in demo.ipynb

This commit is contained in:
Sarvesh 2026-06-09 15:44:41 +05:30
parent 03c4c96dd9
commit 972f44c2fc

View file

@ -146,7 +146,26 @@
" \"target_text\": \"Little boy watering plants outdoors; Using watering can to pour water into flower pot; Shifting camera angle from side view to rear view; Tapping edge of flower pot a few times; Setting down watering can\"\n",
"}\n",
"\n",
"print(f\"Video ID: {sample_example['id']}\")\n",
"import os\n",
"import urllib.request\n",
"\n",
"video_path = sample_example[\"video_path\"]\n",
"if not os.path.exists(video_path):\n",
" print(f\"Video file not found at: {video_path}\")\n",
" print(\"Downloading a public sample video to run the demo...\")\n",
" os.makedirs(os.path.dirname(video_path), exist_ok=True)\n",
" # Download a lightweight sample video (1.8MB)\n",
" sample_url = \"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4\"\n",
" try:\n",
" urllib.request.urlretrieve(sample_url, video_path)\n",
" print(f\"Sample video successfully downloaded to: {video_path}\")\n",
" except Exception as e:\n",
" print(f\"Failed to download sample video: {e}\")\n",
" print(\"Please place a valid video at the path above.\")\n",
"else:\n",
" print(f\"Found video file at: {video_path}\")\n",
"\n",
"print(f\"\\nVideo ID: {sample_example['id']}\")\n",
"print(f\"Prompt: {sample_example['prompt']}\")\n",
"print(f\"Ground Truth: {sample_example['target_text']}\")"
]