Skip to content

Commit 7f36345

Browse files
author
Divyashree Sreepathihalli
committed
Merge remote-tracking branch 'upstream/master' into r0.8
2 parents 446a13b + 3f95d71 commit 7f36345

File tree

9 files changed

+109
-17
lines changed

9 files changed

+109
-17
lines changed

.github/workflows/scorecard.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Scorecard supply-chain security
2+
on:
3+
# For Branch-Protection check. Only the default branch is supported. See
4+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
5+
branch_protection_rule:
6+
# To guarantee Maintained check is occasionally updated. See
7+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
8+
schedule:
9+
- cron: "37 4 * * 6"
10+
push:
11+
branches: [ "master" ]
12+
13+
permissions: read-all
14+
15+
jobs:
16+
analysis:
17+
name: Scorecard analysis
18+
runs-on: ubuntu-latest
19+
permissions:
20+
# Needed to upload the results to code-scanning dashboard.
21+
security-events: write
22+
# Needed to publish results and get a badge (see publish_results below).
23+
id-token: write
24+
25+
steps:
26+
- name: "Checkout code"
27+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
28+
with:
29+
persist-credentials: false
30+
31+
- name: "Run analysis"
32+
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
33+
with:
34+
results_file: results.sarif
35+
results_format: sarif
36+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if
37+
# you want to enable the Branch-Protection check on a *public* repository.
38+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
39+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
40+
41+
# Publish results to OpenSSF REST API for easy access by consumers.
42+
# See https://github.com/ossf/scorecard-action#publishing-results.
43+
publish_results: true
44+
45+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
46+
# format to the repository Actions tab.
47+
- name: "Upload artifact"
48+
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
49+
with:
50+
name: SARIF file
51+
path: results.sarif
52+
retention-days: 5
53+
54+
# Upload the results to GitHub's code scanning dashboard.
55+
- name: "Upload to code-scanning"
56+
uses: github/codeql-action/upload-sarif@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12
57+
with:
58+
sarif_file: results.sarif

keras_cv/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242
from keras_cv.core import NormalFactorSampler
4343
from keras_cv.core import UniformFactorSampler
4444

45-
__version__ = "0.8.0"
45+
__version__ = "0.8.1.dev0"

keras_cv/layers/preprocessing/base_image_augmentation_layer.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
from keras_cv import bounding_box
2525
from keras_cv.api_export import keras_cv_export
26+
from keras_cv.backend import config
2627
from keras_cv.backend import keras
2728
from keras_cv.backend import ops
2829
from keras_cv.backend import scope
@@ -411,14 +412,16 @@ def get_random_transformation(
411412
def call(self, inputs):
412413
# try to convert a given backend native tensor to TensorFlow tensor
413414
# before passing it over to TFDataScope
415+
is_tf_backend = config.backend() == "tensorflow"
416+
is_in_tf_graph = not tf.executing_eagerly()
414417
contains_ragged = lambda y: any(
415418
tree.map_structure(
416419
lambda x: isinstance(x, (tf.RaggedTensor, tf.SparseTensor)),
417420
tree.flatten(y),
418421
)
419422
)
420423
inputs_contain_ragged = contains_ragged(inputs)
421-
if not inputs_contain_ragged:
424+
if not is_tf_backend and not inputs_contain_ragged:
422425
inputs = tree.map_structure(
423426
lambda x: tf.convert_to_tensor(x), inputs
424427
)
@@ -444,13 +447,15 @@ def call(self, inputs):
444447
# backend native tensors. This is to avoid breaking TF data
445448
# pipelines that can't easily be ported to become backend
446449
# agnostic.
447-
if not inputs_contain_ragged and not contains_ragged(outputs):
448-
outputs = tree.map_structure(
449-
# some layers return None, handle that case when
450-
# converting to tensors
451-
lambda x: ops.convert_to_tensor(x) if x is not None else x,
452-
outputs,
453-
)
450+
# Skip this step for TF backend or if in `tf.graph` like `tf.data`.
451+
if not is_tf_backend and not is_in_tf_graph:
452+
if not inputs_contain_ragged and not contains_ragged(outputs):
453+
outputs = tree.map_structure(
454+
# some layers return None, handle that case when
455+
# converting to tensors
456+
lambda x: ops.convert_to_tensor(x) if x is not None else x,
457+
outputs,
458+
)
454459
return outputs
455460

456461
def _augment(self, inputs):

keras_cv/layers/preprocessing/base_image_augmentation_layer_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,11 @@ def in_tf_function(inputs):
265265
self.assertNotAllClose(
266266
segmentation_mask_diff[0], segmentation_mask_diff[1]
267267
)
268+
269+
def test_augment_tf_data_pipeline(self):
270+
image = np.random.random(size=(1, 8, 8, 3)).astype("float32")
271+
tf_dataset = tf.data.Dataset.from_tensor_slices(image).map(
272+
RandomAddLayer(fixed_value=2.0)
273+
)
274+
output = iter(tf_dataset).get_next()
275+
self.assertAllClose(image[0] + 2.0, output)

keras_cv/models/object_detection/yolo_v8/yolo_v8_detector.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,10 +641,31 @@ def get_config(self):
641641
"bounding_box_format": self.bounding_box_format,
642642
"fpn_depth": self.fpn_depth,
643643
"backbone": keras.saving.serialize_keras_object(self.backbone),
644-
"label_encoder": self.label_encoder,
645-
"prediction_decoder": self._prediction_decoder,
644+
"label_encoder": keras.saving.serialize_keras_object(
645+
self.label_encoder
646+
),
647+
"prediction_decoder": keras.saving.serialize_keras_object(
648+
self._prediction_decoder
649+
),
646650
}
647651

652+
@classmethod
653+
def from_config(cls, config):
654+
config["backbone"] = keras.saving.deserialize_keras_object(
655+
config["backbone"]
656+
)
657+
label_encoder = config.get("label_encoder")
658+
if label_encoder is not None:
659+
config["label_encoder"] = keras.saving.deserialize_keras_object(
660+
label_encoder
661+
)
662+
prediction_decoder = config.get("prediction_decoder")
663+
if prediction_decoder is not None:
664+
config[
665+
"prediction_decoder"
666+
] = keras.saving.deserialize_keras_object(prediction_decoder)
667+
return cls(**config)
668+
648669
@classproperty
649670
def presets(cls):
650671
"""Dictionary of preset names and configurations."""

requirements-jax-cuda.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Tensorflow cpu-only version.
2-
tf-nightly-cpu==2.16.0.dev20231221 # Pin a working nightly until rc0.
2+
tf-nightly-cpu==2.16.0.dev20240104 # Pin a working nightly until rc0.
33

44
# Torch cpu-only version.
55
--extra-index-url https://download.pytorch.org/whl/cpu

requirements-tensorflow-cuda.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Tensorflow with cuda support.
2-
tf-nightly[and-cuda]==2.16.0.dev20231221 # Pin a working nightly until rc0.
2+
tf-nightly[and-cuda]==2.16.0.dev20240104 # Pin a working nightly until rc0.
33

44
# Torch cpu-only version.
55
--extra-index-url https://download.pytorch.org/whl/cpu

requirements-torch-cuda.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Tensorflow cpu-only version.
2-
tf-nightly-cpu==2.16.0.dev20231221 # Pin a working nightly until rc0.
2+
tf-nightly-cpu==2.16.0.dev20240104 # Pin a working nightly until rc0.
33

44
# Torch with cuda support.
55
--extra-index-url https://download.pytorch.org/whl/cu121
6-
torch==2.1.2
7-
torchvision==0.16.2
6+
torch==2.1.2+cu121
7+
torchvision==0.16.2+cu121
88

99
# Jax cpu-only version.
1010
jax[cpu]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Tensorflow.
2-
tf-nightly-cpu==2.16.0.dev20231221 # Pin a working nightly until rc0.
2+
tf-nightly-cpu==2.16.0.dev20240104 # Pin a working nightly until rc0.
33

44
# Torch.
55
--extra-index-url https://download.pytorch.org/whl/cpu

0 commit comments

Comments
 (0)