From d39987026bc988bc86b2fca9a260eff3c7da8249 Mon Sep 17 00:00:00 2001 From: idanb Date: Sun, 12 Nov 2023 12:13:24 +0200 Subject: [PATCH] Fix PR comments --- tutorials/notebooks/example_keras_nanodet_plus.ipynb | 4 ++-- tutorials/notebooks/example_keras_yolov8n.ipynb | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tutorials/notebooks/example_keras_nanodet_plus.ipynb b/tutorials/notebooks/example_keras_nanodet_plus.ipynb index 6bcbfe205..1ae7d044e 100644 --- a/tutorials/notebooks/example_keras_nanodet_plus.ipynb +++ b/tutorials/notebooks/example_keras_nanodet_plus.ipynb @@ -266,7 +266,7 @@ "outputs": [], "source": [ "import model_compression_toolkit as mct\n", - "from typing import Iterator, Tuple\n", + "from typing import Iterator, Tuple, List\n", "\n", "REPRESENTATIVE_DATASET_FOLDER = '/content/coco/val2017'\n", "REPRESENTATIVE_DATASET_ANNOTATION_FILE = '/content/coco/annotations/instances_val2017.json'\n", @@ -282,7 +282,7 @@ "def get_representative_dataset(n_iter: int, dataset_loader: Iterator[Tuple]):\n", " \n", " def representative_dataset() -> Iterator[List]:\n", - " ds_iter = iter(train_loader)\n", + " ds_iter = iter(dataset_loader)\n", " for _ in range(n_iter):\n", " yield [next(ds_iter)[0]]\n", "\n", diff --git a/tutorials/notebooks/example_keras_yolov8n.ipynb b/tutorials/notebooks/example_keras_yolov8n.ipynb index 28b8e068d..13cf93770 100644 --- a/tutorials/notebooks/example_keras_yolov8n.ipynb +++ b/tutorials/notebooks/example_keras_yolov8n.ipynb @@ -258,7 +258,7 @@ "outputs": [], "source": [ "import model_compression_toolkit as mct\n", - "from typing import Iterator, Tuple\n", + "from typing import Iterator, Tuple, List\n", "\n", "REPRESENTATIVE_DATASET_FOLDER = '/content/coco/val2017/'\n", "REPRESENTATIVE_DATASET_ANNOTATION_FILE = '/content/coco/annotations/instances_val2017.json'\n", @@ -280,9 +280,12 @@ "\n", " return representative_dataset\n", "\n", + "# Set IMX500-v1 TPC\n", + "tpc = mct.get_target_platform_capabilities(\"tensorflow\", 'imx500', target_platform_version='v1')\n", + "\n", "# Preform post training quantization \n", "quant_model, _ = mct.ptq.keras_post_training_quantization_experimental(model,\n", - " get_representative_dataset(n_iters, representative_dataset))\n", + " get_representative_dataset(n_iters, representative_dataset), target_platform_capabilities=tpc)\n", "\n", "print('Quantized model is ready')" ] @@ -293,7 +296,7 @@ "metadata": {}, "source": [ "### Evaluate quantized model\n", - "Lastly, we can evaluate the performance of the quantized model. There is a slight decrease in performance that can be further mitigated by either expanding the representative dataset or employing MCT's advanced quantization methods, such as EPTQ (Enhanced Post Training Quantization)." + "Lastly, we can evaluate the performance of the quantized model. There is a slight decrease in performance that can be further mitigated by either expanding the representative dataset or employing MCT's advanced quantization methods, such as GPTQ (Gradient-Based/Enhanced Post Training Quantization)." ] }, {