Skip to content

Commit

Permalink
Additional pass on kerascv docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fchollet committed May 17, 2022
1 parent 6ef9c0c commit 02c8525
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 365 deletions.
67 changes: 3 additions & 64 deletions guides/ipynb/keras_cv/coco_metrics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
},
"outputs": [],
"source": [
"i = keras.layers.Input((None, None, 6))\n",
"i = keras.layers.Input((None, 6))\n",
"model = keras.Model(i, i)"
]
},
Expand Down Expand Up @@ -301,71 +301,10 @@
"permutations evaluated in the original COCO challenge, all metrics evaluated in\n",
"the accompanying `pycocotools` library, and more!\n",
"\n",
"### COCORecall\n",
"Check out the full documentation for [`COCORecall`](/api/keras_cv/metrics/coco_recall/) and\n",
"[`COCOMeanAveragePrecision`](/api/keras_cv/metrics/coco_mean_average_precision/).\n",
"\n",
"The COCORecall constructor supports the following parameters\n",
"\n",
"| Name | Usage |\n",
"| --------------- | ---------------------------------------------------------- |\n",
"| iou\\_thresholds | iou\\_thresholds expects an iterable. This value is used as |\n",
": : a cutoff to determine the minimum intersection of unions :\n",
": : required for a classification sample to be considered a :\n",
": : true positive. If an iterable is passed, the result is the :\n",
": : average across IoU values passed in the :\n",
": : iterable.<br>Defaults to `range(0.5, 0.95, incr=0.05)` :\n",
"| area\\_range | area\\_range specifies a range over which to evaluate the |\n",
": : metric. Only ground truth objects within the area\\_range :\n",
": : are considered in the scoring.<br>Defaults to\\: `\\[0, :\n",
": : 1e5\\*\\*2\\]` :\n",
"| max\\_detections | max\\_detections is a value specifying the max number of |\n",
": : detections a model is allowed to make.<br>Defaults to\\: :\n",
": : `100` :\n",
"| class\\_ids | When class\\_ids is not None, the metric will only consider |\n",
": : boxes of the matching class label. This is useful when a :\n",
": : specific class is considered high priority. An example of :\n",
": : this would be providing the human and animal class indices :\n",
": : in the case of self driving cars.<br>To evaluate all :\n",
": : categories, users will pass `range(0, num\\_classes)`. :\n",
"\n",
"### COCOMeanAveragePrecision\n",
"\n",
"The COCOMeanAveragePrecision constructor supports the following parameters\n",
"\n",
"| Name | Usage |\n",
"| ------------------ | ------------------------------------------------------- |\n",
"| \\*\\*kwargs | Passed to COCOBase.super() |\n",
"| recall\\_thresholds | recall\\_thresholds is a list containing the |\n",
": : recall\\_thresholds over which to consider in the :\n",
": : computation of MeanAveragePrecision. :\n",
"| iou\\_thresholds | iou\\_thresholds expects an iterable. This value is used |\n",
": : as a cutoff to determine the minimum intersection of :\n",
": : unions required for a classification sample to be :\n",
": : considered a true positive. If an iterable is passed, :\n",
": : the result is the average across IoU values passed in :\n",
": : the iterable.<br>Defaults to `range(0.5, 0.95, :\n",
": : incr=0.05)` :\n",
"| area\\_range | area\\_range specifies a range over which to evaluate |\n",
": : the metric. Only ground truth objects within the :\n",
": : area\\_range are considered in the :\n",
": : scoring.<br><br>Defaults to\\: `\\[0, 1e5\\*\\*2\\]` :\n",
"| max\\_detections | max\\_detections is a value specifying the max number of |\n",
": : detections a model is allowed to make.<br><br>Defaults :\n",
": : to\\: `100` :\n",
"| class\\_ids | When class\\_ids is not None, the metric will only |\n",
": : consider boxes of the matching class label. This is :\n",
": : useful when a specific class is considered high :\n",
": : priority. An example of this would be providing the :\n",
": : human and animal class indices in the case of self :\n",
": : driving cars.<br>To evaluate all categories, users will :\n",
": : pass `range(0, num\\_classes)`. :"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text"
},
"source": [
"## Conclusion & next steps\n",
"KerasCV makes it easier than ever before to evaluate a Keras object detection model.\n",
"Historically, users had to perform post training evaluation. With KerasCV, you can\n",
Expand Down
64 changes: 4 additions & 60 deletions guides/keras_cv/coco_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
1.) Construct your the metric and a dummy model
"""

i = keras.layers.Input((None, None, 6))
i = keras.layers.Input((None, 6))
model = keras.Model(i, i)

"""
Expand Down Expand Up @@ -152,66 +152,10 @@
permutations evaluated in the original COCO challenge, all metrics evaluated in
the accompanying `pycocotools` library, and more!
### COCORecall
The COCORecall constructor supports the following parameters
| Name | Usage |
| --------------- | ---------------------------------------------------------- |
| iou\_thresholds | iou\_thresholds expects an iterable. This value is used as |
: : a cutoff to determine the minimum intersection of unions :
: : required for a classification sample to be considered a :
: : true positive. If an iterable is passed, the result is the :
: : average across IoU values passed in the :
: : iterable.<br>Defaults to `range(0.5, 0.95, incr=0.05)` :
| area\_range | area\_range specifies a range over which to evaluate the |
: : metric. Only ground truth objects within the area\_range :
: : are considered in the scoring.<br>Defaults to\: `\[0, :
: : 1e5\*\*2\]` :
| max\_detections | max\_detections is a value specifying the max number of |
: : detections a model is allowed to make.<br>Defaults to\: :
: : `100` :
| class\_ids | When class\_ids is not None, the metric will only consider |
: : boxes of the matching class label. This is useful when a :
: : specific class is considered high priority. An example of :
: : this would be providing the human and animal class indices :
: : in the case of self driving cars.<br>To evaluate all :
: : categories, users will pass `range(0, num\_classes)`. :
### COCOMeanAveragePrecision
The COCOMeanAveragePrecision constructor supports the following parameters
| Name | Usage |
| ------------------ | ------------------------------------------------------- |
| \*\*kwargs | Passed to COCOBase.super() |
| recall\_thresholds | recall\_thresholds is a list containing the |
: : recall\_thresholds over which to consider in the :
: : computation of MeanAveragePrecision. :
| iou\_thresholds | iou\_thresholds expects an iterable. This value is used |
: : as a cutoff to determine the minimum intersection of :
: : unions required for a classification sample to be :
: : considered a true positive. If an iterable is passed, :
: : the result is the average across IoU values passed in :
: : the iterable.<br>Defaults to `range(0.5, 0.95, :
: : incr=0.05)` :
| area\_range | area\_range specifies a range over which to evaluate |
: : the metric. Only ground truth objects within the :
: : area\_range are considered in the :
: : scoring.<br><br>Defaults to\: `\[0, 1e5\*\*2\]` :
| max\_detections | max\_detections is a value specifying the max number of |
: : detections a model is allowed to make.<br><br>Defaults :
: : to\: `100` :
| class\_ids | When class\_ids is not None, the metric will only |
: : consider boxes of the matching class label. This is :
: : useful when a specific class is considered high :
: : priority. An example of this would be providing the :
: : human and animal class indices in the case of self :
: : driving cars.<br>To evaluate all categories, users will :
: : pass `range(0, num\_classes)`. :
"""
Check out the full documentation for [`COCORecall`](/api/keras_cv/metrics/coco_recall/) and
[`COCOMeanAveragePrecision`](/api/keras_cv/metrics/coco_mean_average_precision/).
"""
## Conclusion & next steps
KerasCV makes it easier than ever before to evaluate a Keras object detection model.
Historically, users had to perform post training evaluation. With KerasCV, you can
Expand Down
85 changes: 5 additions & 80 deletions guides/md/keras_cv/coco_metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,6 @@ from tensorflow import keras
metric = keras_cv.metrics.COCORecall(class_ids=[1, 2, 3], area_range=(0, 32**2))
```

<div class="k-default-codeblock">
```
2022-05-16 19:04:43.674235: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.tracking.base has been moved to tensorflow.python.trackable.base. The old module will be deleted in version 2.11.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.checkpoint_management has been moved to tensorflow.python.checkpoint.checkpoint_management. The old module will be deleted in version 2.9.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.tracking.resource has been moved to tensorflow.python.trackable.resource. The old module will be deleted in version 2.11.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.tracking.util has been moved to tensorflow.python.checkpoint.checkpoint. The old module will be deleted in version 2.11.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.tracking.base_delegate has been moved to tensorflow.python.trackable.base_delegate. The old module will be deleted in version 2.11.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.tracking.graph_view has been moved to tensorflow.python.checkpoint.graph_view. The old module will be deleted in version 2.11.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.tracking.python_state has been moved to tensorflow.python.trackable.python_state. The old module will be deleted in version 2.11.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.saving.functional_saver has been moved to tensorflow.python.checkpoint.functional_saver. The old module will be deleted in version 2.11.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.saving.checkpoint_options has been moved to tensorflow.python.checkpoint.checkpoint_options. The old module will be deleted in version 2.11.
2022-05-16 19:04:58.090409: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
```
</div>
2.) Create Some Bounding Boxes:


Expand Down Expand Up @@ -147,7 +127,7 @@ process.


```python
i = keras.layers.Input((None, None, 6))
i = keras.layers.Input((None, 6))
model = keras.Model(i, i)
```

Expand Down Expand Up @@ -178,8 +158,7 @@ model.evaluate(y_pred, y_true, return_dict=True)

<div class="k-default-codeblock">
```
WARNING:tensorflow:Model was constructed with shape (None, None, None, 6) for input KerasTensor(type_spec=TensorSpec(shape=(None, None, None, 6), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (None, 2, 6).
1/1 [==============================] - 1s 550ms/step - loss: 0.0000e+00 - coco_recall: 1.0000
1/1 [==============================] - 1s 615ms/step - loss: 0.0000e+00 - coco_recall: 1.0000
{'loss': 0.0, 'coco_recall': 1.0}
Expand All @@ -195,63 +174,9 @@ KerasCV COCO Metrics are sufficiently parameterized to support all of the
permutations evaluated in the original COCO challenge, all metrics evaluated in
the accompanying `pycocotools` library, and more!

### COCORecall

The COCORecall constructor supports the following parameters

| Name | Usage |
| --------------- | ---------------------------------------------------------- |
| iou\_thresholds | iou\_thresholds expects an iterable. This value is used as |
: : a cutoff to determine the minimum intersection of unions :
: : required for a classification sample to be considered a :
: : true positive. If an iterable is passed, the result is the :
: : average across IoU values passed in the :
: : iterable.<br>Defaults to `range(0.5, 0.95, incr=0.05)` :
| area\_range | area\_range specifies a range over which to evaluate the |
: : metric. Only ground truth objects within the area\_range :
: : are considered in the scoring.<br>Defaults to\: `\[0, :
: : 1e5\*\*2\]` :
| max\_detections | max\_detections is a value specifying the max number of |
: : detections a model is allowed to make.<br>Defaults to\: :
: : `100` :
| class\_ids | When class\_ids is not None, the metric will only consider |
: : boxes of the matching class label. This is useful when a :
: : specific class is considered high priority. An example of :
: : this would be providing the human and animal class indices :
: : in the case of self driving cars.<br>To evaluate all :
: : categories, users will pass `range(0, num\_classes)`. :

### COCOMeanAveragePrecision

The COCOMeanAveragePrecision constructor supports the following parameters

| Name | Usage |
| ------------------ | ------------------------------------------------------- |
| \*\*kwargs | Passed to COCOBase.super() |
| recall\_thresholds | recall\_thresholds is a list containing the |
: : recall\_thresholds over which to consider in the :
: : computation of MeanAveragePrecision. :
| iou\_thresholds | iou\_thresholds expects an iterable. This value is used |
: : as a cutoff to determine the minimum intersection of :
: : unions required for a classification sample to be :
: : considered a true positive. If an iterable is passed, :
: : the result is the average across IoU values passed in :
: : the iterable.<br>Defaults to `range(0.5, 0.95, :
: : incr=0.05)` :
| area\_range | area\_range specifies a range over which to evaluate |
: : the metric. Only ground truth objects within the :
: : area\_range are considered in the :
: : scoring.<br><br>Defaults to\: `\[0, 1e5\*\*2\]` :
| max\_detections | max\_detections is a value specifying the max number of |
: : detections a model is allowed to make.<br><br>Defaults :
: : to\: `100` :
| class\_ids | When class\_ids is not None, the metric will only |
: : consider boxes of the matching class label. This is :
: : useful when a specific class is considered high :
: : priority. An example of this would be providing the :
: : human and animal class indices in the case of self :
: : driving cars.<br>To evaluate all categories, users will :
: : pass `range(0, num\_classes)`. :
Check out the full documentation for [`COCORecall`](/api/keras_cv/metrics/coco_recall/) and
[`COCOMeanAveragePrecision`](/api/keras_cv/metrics/coco_mean_average_precision/).


---
## Conclusion & next steps
Expand Down
Loading

0 comments on commit 02c8525

Please sign in to comment.