Skip to content

Commit

Permalink
Update instructions for using with KerasCV
Browse files Browse the repository at this point in the history
  • Loading branch information
bhky committed Jun 30, 2024
1 parent 0620043 commit e7a7833
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,20 +210,25 @@ ds = ds.padded_batch(batch_size=2, padding_values=-1.0)
```

### Using with KerasCV
The [KerasCV](https://keras.io/keras_cv/) API has a little bit confusing format
regarding the bounding boxes, depending on whether the users are preparing
the inputs for a preprocessing layer, or for a model.
The [KerasCV](https://keras.io/keras_cv/) API is a little bit confusing
in terms of its input data format. The requirement is different between
a preprocessing layer and a model.

Targetran also provides easy conversion tools to make the process smoother.
Targetran provides easy conversion tools to make the process smoother.
```python
import keras_cv
from targetran.tf import to_keras_cv_dict, to_keras_cv_model_input

# The resulting dataset yields batches readily to be passed to a KerasCV
# preprocessing layer. Batching in the appropriate format can be done directly
# with this call, therefore the above `padded_batch` example is not relevant here.
# Let's assume `ds` contains Targetran ops as in the above illustration,
# but without batching. To map the outputs to a KerasCV preprocessing layer,
# the following can be done to get the required data format.
ds = to_keras_cv_dict(ds, batch_size=2)

# The resulting dataset yields batches readily to be passed to a KerasCV
# preprocessing layer. Batching in the appropriate format is done directly
# with this call, therefore the `padded_batch` example is not relevant here.

# Assume the user would like to add a jittered-resize op.
jittered_resize = keras_cv.layers.JitteredResize(
target_size=(640, 640),
scale_factor=(0.8, 1.25),
Expand Down

0 comments on commit e7a7833

Please sign in to comment.