Commit 34731381 authored by Dan Kondratyuk's avatar Dan Kondratyuk Committed by A. Unique TensorFlower
Browse files

Fix movinet colab references.

PiperOrigin-RevId: 374217229
parent e04eb07b
......@@ -40,7 +40,7 @@
},
"outputs": [],
"source": [
"!pip install -q tf-models-nightly\n",
"!pip install -q tf-models-nightly tfds-nightly\n",
"\n",
"!command -v ffmpeg \u003e/dev/null || (apt update \u0026\u0026 apt install -y ffmpeg)\n",
"!pip install -q mediapy"
......@@ -54,7 +54,6 @@
},
"outputs": [],
"source": [
"from io import BytesIO\n",
"import os\n",
"from six.moves import urllib\n",
"\n",
......@@ -68,7 +67,7 @@
"\n",
"from official.vision.beta.configs import video_classification\n",
"from official.vision.beta.projects.movinet.configs import movinet as movinet_configs\n",
"from official.vision.beta.projects.movinet.modeling import movinet as movinet_backbone\n",
"from official.vision.beta.projects.movinet.modeling import movinet\n",
"from official.vision.beta.projects.movinet.modeling import movinet_layers\n",
"from official.vision.beta.projects.movinet.modeling import movinet_model"
]
......@@ -138,7 +137,7 @@
"image_width = 224\n",
"\n",
"with urllib.request.urlopen(image_url) as f:\n",
" image = Image.open(BytesIO(f.read())).resize((image_height, image_width))\n",
" image = Image.open(f).resize((image_height, image_width))\n",
"video = tf.reshape(np.array(image), [1, 1, image_height, image_width, 3])\n",
"video = tf.cast(video, tf.float32) / 255.\n",
"\n",
......@@ -200,6 +199,22 @@
"Calling `download_and_prepare()` will automatically download the dataset. After downloading, this cell will output information about the dataset."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "FxM1vNYp_YAM"
},
"outputs": [],
"source": [
"dataset_name = 'ucf101'\n",
"\n",
"builder = tfds.builder(dataset_name)\n",
"\n",
"config = tfds.download.DownloadConfig(verify_ssl=False)\n",
"builder.download_and_prepare(download_config=config)"
]
},
{
"cell_type": "code",
"execution_count": null,
......@@ -281,11 +296,6 @@
}
],
"source": [
"dataset_name = 'ucf101'\n",
"\n",
"builder = tfds.builder(dataset_name)\n",
"builder.download_and_prepare()\n",
"\n",
"num_classes = builder.info.features['label'].num_classes\n",
"num_examples = {\n",
" name: split.num_examples\n",
......@@ -407,12 +417,10 @@
"tf.keras.backend.clear_session()\n",
"\n",
"backbone = movinet.Movinet(\n",
" model_id=model_id,\n",
" stochastic_depth_rate=0.)\n",
" model_id=model_id)\n",
"model = movinet_model.MovinetClassifier(\n",
" backbone=backbone,\n",
" num_classes=600,\n",
" dropout_rate=0.)\n",
" num_classes=600)\n",
"model.build([batch_size, num_frames, resolution, resolution, 3])\n",
"\n",
"# Load pretrained weights from TF Hub\n",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment