Skip to content

Commit

Permalink
Merge pull request #11110 from tensorflow:sineeli-patch-14
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 580979537
  • Loading branch information
laxmareddyp committed Nov 9, 2023
2 parents 8eaf42f + ad1f7b5 commit 55eb1d6
Show file tree
Hide file tree
Showing 44 changed files with 6,273 additions and 75 deletions.
120 changes: 46 additions & 74 deletions docs/vision/object_detection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@
},
"source": [
"# Object detection with Model Garden\n",
"\u003ctable class=\"tfo-notebook-buttons\" align=\"left\"\u003e\n",
" \u003ctd\u003e\n",
" \u003ca target=\"_blank\" href=\"https://www.tensorflow.org/tfmodels/vision/object_detection\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/tf_logo_32px.png\" /\u003eView on TensorFlow.org\u003c/a\u003e\n",
" \u003c/td\u003e\n",
" \u003ctd\u003e\n",
" \u003ca target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/models/blob/master/docs/vision/object_detection.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" /\u003eRun in Google Colab\u003c/a\u003e\n",
" \u003c/td\u003e\n",
" \u003ctd\u003e\n",
" \u003ca target=\"_blank\" href=\"https://github.com/tensorflow/models/blob/master/docs/vision/object_detection.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" /\u003eView on GitHub\u003c/a\u003e\n",
" \u003c/td\u003e\n",
" \u003ctd\u003e\n",
" \u003ca href=\"https://storage.googleapis.com/tensorflow_docs/models/docs/vision/object_detection.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/download_logo_32px.png\" /\u003eDownload notebook\u003c/a\u003e\n",
" \u003c/td\u003e\n",
"\u003c/table\u003e"
"<table class=\"tfo-notebook-buttons\" align=\"left\">\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://www.tensorflow.org/tfmodels/vision/object_detection\"><img src=\"https://www.tensorflow.org/images/tf_logo_32px.png\" />View on TensorFlow.org</a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/models/blob/master/docs/vision/object_detection.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://github.com/tensorflow/models/blob/master/docs/vision/object_detection.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View on GitHub</a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://storage.googleapis.com/tensorflow_docs/models/docs/vision/object_detection.ipynb\"><img src=\"https://www.tensorflow.org/images/download_logo_32px.png\" />Download notebook</a>\n",
" </td>\n",
"</table>"
]
},
{
Expand Down Expand Up @@ -87,7 +87,7 @@
},
"outputs": [],
"source": [
"!pip install -U -q \"tensorflow\" \"tf-models-official\""
"!pip install -U -q \"tf-models-official\""
]
},
{
Expand Down Expand Up @@ -170,26 +170,6 @@
"Please check [this resource](https://www.tensorflow.org/tutorials/load_data/tfrecord) to learn more about TFRecords data format.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "YcFW-xHRZ1xJ"
},
"source": [
"### clone the model-garden repo as the required data conversion codes are within this model-garden repository"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "tZLidUjiY1xt"
},
"outputs": [],
"source": [
"!git clone --quiet https://github.com/tensorflow/models.git"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -207,31 +187,11 @@
},
"outputs": [],
"source": [
"!curl -L 'https://public.roboflow.com/ds/ZpYLqHeT0W?key=ZXfZLRnhsc' \u003e './BCCD.v1-bccd.coco.zip'\n",
"!curl -L 'https://public.roboflow.com/ds/ZpYLqHeT0W?key=ZXfZLRnhsc' > './BCCD.v1-bccd.coco.zip'\n",
"!unzip -q -o './BCCD.v1-bccd.coco.zip' -d './BCC.v1-bccd.coco/'\n",
"!rm './BCCD.v1-bccd.coco.zip'"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "jKJ3MtgeZ5om"
},
"source": [
"### Change directory to vision or data where data conversion tools are available"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "IYM7PIFbY5EL"
},
"outputs": [],
"source": [
"%cd ./models/"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -251,9 +211,9 @@
"source": [
"%%bash\n",
"\n",
"TRAIN_DATA_DIR='../BCC.v1-bccd.coco/train'\n",
"TRAIN_ANNOTATION_FILE_DIR='../BCC.v1-bccd.coco/train/_annotations.coco.json'\n",
"OUTPUT_TFRECORD_TRAIN='../bccd_coco_tfrecords/train'\n",
"TRAIN_DATA_DIR='./BCC.v1-bccd.coco/train'\n",
"TRAIN_ANNOTATION_FILE_DIR='./BCC.v1-bccd.coco/train/_annotations.coco.json'\n",
"OUTPUT_TFRECORD_TRAIN='./bccd_coco_tfrecords/train'\n",
"\n",
"# Need to provide\n",
" # 1. image_dir: where images are present\n",
Expand Down Expand Up @@ -285,9 +245,9 @@
"source": [
"%%bash\n",
"\n",
"VALID_DATA_DIR='../BCC.v1-bccd.coco/valid'\n",
"VALID_ANNOTATION_FILE_DIR='../BCC.v1-bccd.coco/valid/_annotations.coco.json'\n",
"OUTPUT_TFRECORD_VALID='../bccd_coco_tfrecords/valid'\n",
"VALID_DATA_DIR='./BCC.v1-bccd.coco/valid'\n",
"VALID_ANNOTATION_FILE_DIR='./BCC.v1-bccd.coco/valid/_annotations.coco.json'\n",
"OUTPUT_TFRECORD_VALID='./bccd_coco_tfrecords/valid'\n",
"\n",
"python -m official.vision.data.create_coco_tf_record --logtostderr \\\n",
" --image_dir=$VALID_DATA_DIR \\\n",
Expand Down Expand Up @@ -315,9 +275,9 @@
"source": [
"%%bash\n",
"\n",
"TEST_DATA_DIR='../BCC.v1-bccd.coco/test'\n",
"TEST_ANNOTATION_FILE_DIR='../BCC.v1-bccd.coco/test/_annotations.coco.json'\n",
"OUTPUT_TFRECORD_TEST='../bccd_coco_tfrecords/test'\n",
"TEST_DATA_DIR='./BCC.v1-bccd.coco/test'\n",
"TEST_ANNOTATION_FILE_DIR='./BCC.v1-bccd.coco/test/_annotations.coco.json'\n",
"OUTPUT_TFRECORD_TEST='./bccd_coco_tfrecords/test'\n",
"\n",
"python -m official.vision.data.create_coco_tf_record --logtostderr \\\n",
" --image_dir=$TEST_DATA_DIR \\\n",
Expand Down Expand Up @@ -345,11 +305,11 @@
},
"outputs": [],
"source": [
"train_data_input_path = '../bccd_coco_tfrecords/train-00000-of-00001.tfrecord'\n",
"valid_data_input_path = '../bccd_coco_tfrecords/valid-00000-of-00001.tfrecord'\n",
"test_data_input_path = '../bccd_coco_tfrecords/test-00000-of-00001.tfrecord'\n",
"model_dir = '../trained_model/'\n",
"export_dir ='../exported_model/'"
"train_data_input_path = './bccd_coco_tfrecords/train-00000-of-00001.tfrecord'\n",
"valid_data_input_path = './bccd_coco_tfrecords/valid-00000-of-00001.tfrecord'\n",
"test_data_input_path = './bccd_coco_tfrecords/test-00000-of-00001.tfrecord'\n",
"model_dir = './trained_model/'\n",
"export_dir ='./exported_model/'"
]
},
{
Expand Down Expand Up @@ -534,7 +494,7 @@
"source": [
"## Create the `Task` object (`tfm.core.base_task.Task`) from the `config_definitions.TaskConfig`.\n",
"\n",
"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`."
"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`."
]
},
{
Expand Down Expand Up @@ -699,7 +659,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"metadata": {
"id": "SCjHHXvfZXX1"
},
Expand Down Expand Up @@ -732,7 +692,7 @@
"outputs": [],
"source": [
"%load_ext tensorboard\n",
"%tensorboard --logdir '../trained_model/'"
"%tensorboard --logdir './trained_model/'"
]
},
{
Expand Down Expand Up @@ -840,7 +800,7 @@
"num_of_examples = 3\n",
"\n",
"test_ds = tf.data.TFRecordDataset(\n",
" '../bccd_coco_tfrecords/test-00000-of-00001.tfrecord').take(\n",
" './bccd_coco_tfrecords/test-00000-of-00001.tfrecord').take(\n",
" num_of_examples)\n",
"show_batch(test_ds, num_of_examples)"
]
Expand Down Expand Up @@ -923,6 +883,18 @@
"kernelspec": {
"display_name": "Python 3",
"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.8"
}
},
"nbformat": 4,
Expand Down
14 changes: 14 additions & 0 deletions official/projects/waste_identification_ml/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Loading

0 comments on commit 55eb1d6

Please sign in to comment.