From 6aba0fc458456023e77940725a73f9891e4c7420 Mon Sep 17 00:00:00 2001
From: sineeli <113718461+sineeli@users.noreply.github.com>
Date: Mon, 6 Nov 2023 19:25:30 +0000
Subject: [PATCH 1/2] remove repo cloning and adjust folder paths
---
docs/vision/object_detection.ipynb | 118 +++++++++++------------------
1 file changed, 45 insertions(+), 73 deletions(-)
diff --git a/docs/vision/object_detection.ipynb b/docs/vision/object_detection.ipynb
index 8c0319382d5..723982ac3b0 100644
--- a/docs/vision/object_detection.ipynb
+++ b/docs/vision/object_detection.ipynb
@@ -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"
+ "
"
]
},
{
@@ -87,7 +87,7 @@
},
"outputs": [],
"source": [
- "!pip install -U -q \"tensorflow\" \"tf-models-official\""
+ "!pip install -U -q \"tf-models-official\""
]
},
{
@@ -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": {
@@ -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": {
@@ -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",
@@ -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",
@@ -315,8 +275,8 @@
"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",
+ "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",
@@ -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/'"
]
},
{
@@ -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`."
]
},
{
@@ -699,7 +659,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 18,
"metadata": {
"id": "SCjHHXvfZXX1"
},
@@ -732,7 +692,7 @@
"outputs": [],
"source": [
"%load_ext tensorboard\n",
- "%tensorboard --logdir '../trained_model/'"
+ "%tensorboard --logdir './trained_model/'"
]
},
{
@@ -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)"
]
@@ -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,
From ad1f7b56943998864db8f5db0706950e93bb7d81 Mon Sep 17 00:00:00 2001
From: sineeli <113718461+sineeli@users.noreply.github.com>
Date: Mon, 6 Nov 2023 19:26:15 +0000
Subject: [PATCH 2/2] adjust folder path
---
docs/vision/object_detection.ipynb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/vision/object_detection.ipynb b/docs/vision/object_detection.ipynb
index 723982ac3b0..f27c4b0d509 100644
--- a/docs/vision/object_detection.ipynb
+++ b/docs/vision/object_detection.ipynb
@@ -277,7 +277,7 @@
"\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",
+ "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",