Skip to content

Commit b4e3296

Browse files
author
(Ian Stenbit)
committed
Re-run formatter
1 parent 9df2d03 commit b4e3296

File tree

13 files changed

+57
-18
lines changed

13 files changed

+57
-18
lines changed

examples/layers/preprocessing/cut_mix_demo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def resize(image, label, num_classes=10):
2121

2222

2323
def main():
24-
data, ds_info = tfds.load("oxford_flowers102", with_info=True, as_supervised=True)
24+
data, ds_info = tfds.load(
25+
"oxford_flowers102", with_info=True, as_supervised=True
26+
)
2527
train_ds = data["train"]
2628

2729
num_classes = ds_info.features["label"].num_classes

examples/layers/preprocessing/mix_up_demo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def resize(image, label, num_classes=10):
2121

2222

2323
def main():
24-
data, ds_info = tfds.load("oxford_flowers102", with_info=True, as_supervised=True)
24+
data, ds_info = tfds.load(
25+
"oxford_flowers102", with_info=True, as_supervised=True
26+
)
2527
train_ds = data["train"]
2628

2729
num_classes = ds_info.features["label"].num_classes

keras_cv/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from keras_cv import layers, metrics, util
15+
from keras_cv import layers
16+
from keras_cv import metrics
17+
from keras_cv import util

keras_cv/layers/preprocessing/cut_mix.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,12 @@ def _cutmix(self, images, labels):
8787
input_shape[2],
8888
)
8989

90-
permutation_order = tf.random.shuffle(tf.range(0, batch_size), seed=self.seed)
91-
lambda_sample = CutMix._sample_from_beta(self.alpha, self.alpha, (batch_size,))
90+
permutation_order = tf.random.shuffle(
91+
tf.range(0, batch_size), seed=self.seed
92+
)
93+
lambda_sample = CutMix._sample_from_beta(
94+
self.alpha, self.alpha, (batch_size,)
95+
)
9296

9397
ratio = tf.math.sqrt(1 - lambda_sample)
9498

@@ -130,7 +134,9 @@ def _update_labels(self, images, labels, lambda_sample, permutation_order):
130134
cutout_labels = tf.gather(labels, permutation_order)
131135

132136
lambda_sample = tf.reshape(lambda_sample, [-1, 1])
133-
labels = lambda_sample * labels_smoothed + (1.0 - lambda_sample) * cutout_labels
137+
labels = (
138+
lambda_sample * labels_smoothed + (1.0 - lambda_sample) * cutout_labels
139+
)
134140
return images, labels
135141

136142
def _smooth_labels(self, labels):

keras_cv/layers/preprocessing/mix_up.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,13 @@ def call(self, images, labels):
8080

8181
def _mixup(self, images, labels):
8282
batch_size = tf.shape(images)[0]
83-
permutation_order = tf.random.shuffle(tf.range(0, batch_size), seed=self.seed)
83+
permutation_order = tf.random.shuffle(
84+
tf.range(0, batch_size), seed=self.seed
85+
)
8486

85-
lambda_sample = MixUp._sample_from_beta(self.alpha, self.alpha, (batch_size,))
87+
lambda_sample = MixUp._sample_from_beta(
88+
self.alpha, self.alpha, (batch_size,)
89+
)
8690
lambda_sample = tf.reshape(lambda_sample, [-1, 1, 1, 1])
8791

8892
mixup_images = tf.gather(images, permutation_order)
@@ -96,7 +100,8 @@ def _update_labels(self, images, labels, lambda_sample, permutation_order):
96100

97101
lambda_sample = tf.reshape(lambda_sample, [-1, 1])
98102
labels = (
99-
lambda_sample * labels_smoothed + (1.0 - lambda_sample) * labels_for_mixup
103+
lambda_sample * labels_smoothed
104+
+ (1.0 - lambda_sample) * labels_for_mixup
100105
)
101106

102107
return images, labels

keras_cv/metrics/coco/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ def update_state(self, y_true, y_pred, sample_weight=None):
137137
false_positives = tf.cast(pred_matches == -1, tf.float32)
138138

139139
true_positives_sum = tf.math.reduce_sum(true_positives, axis=-1)
140-
false_positives_sum = tf.math.reduce_sum(false_positives, axis=-1)
140+
false_positives_sum = tf.math.reduce_sum(
141+
false_positives, axis=-1
142+
)
141143

142144
true_positives_update = tf.tensor_scatter_nd_add(
143145
true_positives_update, [indices], [true_positives_sum]

keras_cv/metrics/coco/base_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def test_true_positive_counting_one_true_two_pred(self):
5353
dtype=tf.float32,
5454
)
5555
y_pred = tf.constant(
56-
[[[0, 50, 100, 150, 1, 0.90], [0, 0, 100, 100, 1, 1.0]]], dtype=tf.float32
56+
[[[0, 50, 100, 150, 1, 0.90], [0, 0, 100, 100, 1, 1.0]]],
57+
dtype=tf.float32,
5758
)
5859
# note the low iou threshold
5960
metric = COCOBase(

keras_cv/metrics/coco/iou.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def _compute_single_iou(bboxes1, bb2):
3535
area_bboxes1 = _area(
3636
bb1[bbox.LEFT], bb1[bbox.RIGHT], bb1[bbox.TOP], bb1[bbox.BOTTOM]
3737
)
38-
area_bb2 = _area(bb2[bbox.LEFT], bb2[bbox.RIGHT], bb2[bbox.TOP], bb2[bbox.BOTTOM])
38+
area_bb2 = _area(
39+
bb2[bbox.LEFT], bb2[bbox.RIGHT], bb2[bbox.TOP], bb2[bbox.BOTTOM]
40+
)
3941

4042
area_union = area_bboxes1 + area_bb2 - area_intersection
4143
return tf.math.divide_no_nan(area_intersection, area_union)

keras_cv/metrics/coco/numerical_tests/GenerateSamples.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,9 @@
426426
"for annotation in results:\n",
427427
" img_id = annotation[\"image_id\"]\n",
428428
" bbox = annotation[\"bbox\"]\n",
429-
" bbox = [x for x in bbox] + [int(annotation[\"category_id\"])] + [annotation[\"score\"]]\n",
429+
" bbox = (\n",
430+
" [x for x in bbox] + [int(annotation[\"category_id\"])] + [annotation[\"score\"]]\n",
431+
" )\n",
430432
" groups[img_id].append(bbox)\n",
431433
"\n",
432434
"imgs = sorted(groups.keys())\n",

keras_cv/metrics/coco/recall_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ def test_recall_area_range_filtering(self):
1717
k = recall.category_ids.shape[0]
1818

1919
# These would match if they were in the area range
20-
y_true = np.array([[[0, 0, 10, 10, 1], [5, 5, 10, 10, 1]]]).astype(np.float32)
20+
y_true = np.array([[[0, 0, 10, 10, 1], [5, 5, 10, 10, 1]]]).astype(
21+
np.float32
22+
)
2123
y_pred = np.array([[[0, 0, 10, 10, 1, 1.0], [5, 5, 10, 10, 1, 0.9]]]).astype(
2224
np.float32
2325
)

0 commit comments

Comments
 (0)