Skip to content

Commit ab7774b

Browse files
committed
Add eval summary argument to fix notebook breakage
1 parent 3256e10 commit ab7774b

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

docs/vision/semantic_segmentation.ipynb

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@
3939
"source": [
4040
"# Semantic Segmentation with Model Garden\n",
4141
"\n",
42-
"\u003ctable class=\"tfo-notebook-buttons\" align=\"left\"\u003e\n",
43-
" \u003ctd\u003e\n",
44-
" \u003ca target=\"_blank\" href=\"https://www.tensorflow.org/tfmodels/vision/semantic_segmentation\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/tf_logo_32px.png\" /\u003eView on TensorFlow.org\u003c/a\u003e\n",
45-
" \u003c/td\u003e\n",
46-
" \u003ctd\u003e\n",
47-
" \u003ca target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/models/blob/master/docs/vision/semantic_segmentation.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" /\u003eRun in Google Colab\u003c/a\u003e\n",
48-
" \u003c/td\u003e\n",
49-
" \u003ctd\u003e\n",
50-
" \u003ca target=\"_blank\" href=\"https://github.com/tensorflow/models/blob/master/docs/vision/semantic_segmentation.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" /\u003eView on GitHub\u003c/a\u003e\n",
51-
" \u003c/td\u003e\n",
52-
" \u003ctd\u003e\n",
53-
" \u003ca href=\"https://storage.googleapis.com/tensorflow_docs/models/docs/vision/semantic_segmentation.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/download_logo_32px.png\" /\u003eDownload notebook\u003c/a\u003e\n",
54-
" \u003c/td\u003e\n",
55-
"\u003c/table\u003e"
42+
"<table class=\"tfo-notebook-buttons\" align=\"left\">\n",
43+
" <td>\n",
44+
" <a target=\"_blank\" href=\"https://www.tensorflow.org/tfmodels/vision/semantic_segmentation\"><img src=\"https://www.tensorflow.org/images/tf_logo_32px.png\" />View on TensorFlow.org</a>\n",
45+
" </td>\n",
46+
" <td>\n",
47+
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/models/blob/master/docs/vision/semantic_segmentation.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n",
48+
" </td>\n",
49+
" <td>\n",
50+
" <a target=\"_blank\" href=\"https://github.com/tensorflow/models/blob/master/docs/vision/semantic_segmentation.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View on GitHub</a>\n",
51+
" </td>\n",
52+
" <td>\n",
53+
" <a href=\"https://storage.googleapis.com/tensorflow_docs/models/docs/vision/semantic_segmentation.ipynb\"><img src=\"https://www.tensorflow.org/images/download_logo_32px.png\" />Download notebook</a>\n",
54+
" </td>\n",
55+
"</table>"
5656
]
5757
},
5858
{
@@ -95,7 +95,7 @@
9595
},
9696
"outputs": [],
9797
"source": [
98-
"!pip install -U -q \"tensorflow\u003e=2.9.2\" \"tf-models-official\""
98+
"!pip install -U -q \"tf-models-official\""
9999
]
100100
},
101101
{
@@ -428,7 +428,8 @@
428428
"exp_config.task.validation_data.output_size = [HEIGHT, WIDTH]\n",
429429
"exp_config.task.validation_data.preserve_aspect_ratio = False\n",
430430
"exp_config.task.validation_data.groundtruth_padded_size = [HEIGHT, WIDTH]\n",
431-
"exp_config.task.validation_data.seed = 21 # Reproducable Validation Data"
431+
"exp_config.task.validation_data.seed = 21 # Reproducable Validation Data\n",
432+
"exp_config.task.validation_data.resize_eval_groundtruth = True # To enable validation loss"
432433
]
433434
},
434435
{
@@ -540,7 +541,7 @@
540541
"source": [
541542
"## Create the `Task` object (`tfm.core.base_task.Task`) from the `config_definitions.TaskConfig`.\n",
542543
"\n",
543-
"The `Task` object has all the methods necessary for building the dataset, building the model, and running training \u0026 evaluation. These methods are driven by `tfm.core.train_lib.run_experiment`."
544+
"The `Task` object has all the methods necessary for building the dataset, building the model, and running training & evaluation. These methods are driven by `tfm.core.train_lib.run_experiment`."
544545
]
545546
},
546547
{
@@ -597,7 +598,7 @@
597598
},
598599
"outputs": [],
599600
"source": [
600-
"def display(display_list):\n",
601+
"def plot_masks(display_list):\n",
601602
" plt.figure(figsize=(15, 15))\n",
602603
"\n",
603604
" title = ['Input Image', 'True Mask', 'Predicted Mask']\n",
@@ -636,7 +637,7 @@
636637
"num_examples = 3\n",
637638
"\n",
638639
"for images, masks in task.build_inputs(exp_config.task.train_data).take(num_examples):\n",
639-
" display([images[0], masks['masks'][0]])"
640+
" plot_masks([images[0], masks['masks'][0]])"
640641
]
641642
},
642643
{
@@ -657,12 +658,15 @@
657658
},
658659
"outputs": [],
659660
"source": [
661+
"\n",
660662
"model, eval_logs = tfm.core.train_lib.run_experiment(\n",
661663
" distribution_strategy=distribution_strategy,\n",
662664
" task=task,\n",
663665
" mode='train_and_eval',\n",
664666
" params=exp_config,\n",
665667
" model_dir=model_dir,\n",
668+
" eval_summary_manager=summary_manager.maybe_build_eval_summary_manager(\n",
669+
" params=exp_config, model_dir=model_dir),\n",
666670
" run_post_eval=True)"
667671
]
668672
},
@@ -764,7 +768,7 @@
764768
" image = tf.cast(image, dtype=tf.uint8)\n",
765769
" mask = tf.image.resize(record['segmentation_mask'], size=[HEIGHT, WIDTH])\n",
766770
" predicted_mask = model_fn(tf.expand_dims(record['image'], axis=0))\n",
767-
" display([image, mask, create_mask(predicted_mask['logits'])])"
771+
" plot_masks([image, mask, create_mask(predicted_mask['logits'])])"
768772
]
769773
}
770774
],

0 commit comments

Comments
 (0)