Skip to content

Commit fd551a4

Browse files
author
(Ian Stenbit)
committed
Remove line length of 85.
This was inhereted from a legacy thing. It's not relevant for KerasCV.
1 parent b4ef8ef commit fd551a4

File tree

16 files changed

+41
-76
lines changed

16 files changed

+41
-76
lines changed

examples/layers/preprocessing/cut_mix_demo.py

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

2222

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

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

examples/layers/preprocessing/mix_up_demo.py

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

2222

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

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

examples/layers/preprocessing/random_cutout_demo.py

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

2222

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

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

keras_cv/layers/preprocessing/cut_mix.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,8 @@ def _cutmix(self, images, labels):
9797
input_shape[2],
9898
)
9999

100-
permutation_order = tf.random.shuffle(
101-
tf.range(0, batch_size), seed=self.seed
102-
)
103-
lambda_sample = CutMix._sample_from_beta(
104-
self.alpha, self.alpha, (batch_size,)
105-
)
100+
permutation_order = tf.random.shuffle(tf.range(0, batch_size), seed=self.seed)
101+
lambda_sample = CutMix._sample_from_beta(self.alpha, self.alpha, (batch_size,))
106102

107103
ratio = tf.math.sqrt(1 - lambda_sample)
108104

@@ -144,9 +140,7 @@ def _update_labels(self, images, labels, lambda_sample, permutation_order):
144140
cutout_labels = tf.gather(labels, permutation_order)
145141

146142
lambda_sample = tf.reshape(lambda_sample, [-1, 1])
147-
labels = (
148-
lambda_sample * labels_smoothed + (1.0 - lambda_sample) * cutout_labels
149-
)
143+
labels = lambda_sample * labels_smoothed + (1.0 - lambda_sample) * cutout_labels
150144
return images, labels
151145

152146
def _smooth_labels(self, labels):

keras_cv/layers/preprocessing/mix_up.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,9 @@ def call(self, images, labels, training=True):
8888

8989
def _mixup(self, images, labels):
9090
batch_size = tf.shape(images)[0]
91-
permutation_order = tf.random.shuffle(
92-
tf.range(0, batch_size), seed=self.seed
93-
)
91+
permutation_order = tf.random.shuffle(tf.range(0, batch_size), seed=self.seed)
9492

95-
lambda_sample = MixUp._sample_from_beta(
96-
self.alpha, self.alpha, (batch_size,)
97-
)
93+
lambda_sample = MixUp._sample_from_beta(self.alpha, self.alpha, (batch_size,))
9894
lambda_sample = tf.reshape(lambda_sample, [-1, 1, 1, 1])
9995

10096
mixup_images = tf.gather(images, permutation_order)
@@ -108,8 +104,7 @@ def _update_labels(self, images, labels, lambda_sample, permutation_order):
108104

109105
lambda_sample = tf.reshape(lambda_sample, [-1, 1])
110106
labels = (
111-
lambda_sample * labels_smoothed
112-
+ (1.0 - lambda_sample) * labels_for_mixup
107+
lambda_sample * labels_smoothed + (1.0 - lambda_sample) * labels_for_mixup
113108
)
114109

115110
return images, labels

keras_cv/metrics/coco/base.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(
4141
self,
4242
category_ids,
4343
iou_thresholds=None,
44-
area_range=(0, 1e9 ** 2),
44+
area_range=(0, 1e9**2),
4545
max_detections=100,
4646
**kwargs
4747
):
@@ -150,9 +150,7 @@ def update_state(self, y_true, y_pred, sample_weight=None):
150150
false_positives = tf.cast(pred_matches == -1, tf.float32)
151151

152152
true_positives_sum = tf.math.reduce_sum(true_positives, axis=-1)
153-
false_positives_sum = tf.math.reduce_sum(
154-
false_positives, axis=-1
155-
)
153+
false_positives_sum = tf.math.reduce_sum(false_positives, axis=-1)
156154

157155
true_positives_update = tf.tensor_scatter_nd_add(
158156
true_positives_update, [indices], [true_positives_sum]

keras_cv/metrics/coco/base_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_area_range_bounding_box_counting(self):
2828
metric = COCOBase(
2929
iou_thresholds=[0.15],
3030
category_ids=[1],
31-
area_range=(0, 10000 ** 2),
31+
area_range=(0, 10000**2),
3232
max_detections=1,
3333
)
3434
metric.update_state(y_true, y_pred)
@@ -46,7 +46,7 @@ def test_true_positive_counting_one_good_one_bad(self):
4646
metric = COCOBase(
4747
iou_thresholds=[0.15],
4848
category_ids=[1],
49-
area_range=(0, 10000 ** 2),
49+
area_range=(0, 10000**2),
5050
max_detections=1,
5151
)
5252
metric.update_state(y_true, y_pred)
@@ -72,7 +72,7 @@ def test_true_positive_counting_one_true_two_pred(self):
7272
metric = COCOBase(
7373
iou_thresholds=[0.15],
7474
category_ids=[1],
75-
area_range=(0, 10000 ** 2),
75+
area_range=(0, 10000**2),
7676
max_detections=1,
7777
)
7878
metric.update_state(y_true, y_pred)
@@ -93,7 +93,7 @@ def test_matches_single_box(self):
9393
metric = COCOBase(
9494
iou_thresholds=[0.15],
9595
category_ids=[1],
96-
area_range=(0, 10000 ** 2),
96+
area_range=(0, 10000**2),
9797
max_detections=1,
9898
)
9999
metric.update_state(y_true, y_pred)
@@ -110,7 +110,7 @@ def test_matches_single_false_positive(self):
110110
metric = COCOBase(
111111
iou_thresholds=[0.95],
112112
category_ids=[1],
113-
area_range=(0, 100000 ** 2),
113+
area_range=(0, 100000**2),
114114
max_detections=1,
115115
)
116116
metric.update_state(y_true, y_pred)

keras_cv/metrics/coco/numerical_tests/GenerateSamples.ipynb

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

keras_cv/metrics/coco/numerical_tests/recall_correctness_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_recall_correctness_maxdets_1(self):
4949
recall = COCORecall(
5050
category_ids=categories + [1000],
5151
max_detections=1,
52-
area_range=(0, 1e5 ** 2),
52+
area_range=(0, 1e5**2),
5353
)
5454

5555
recall.update_state(y_true, y_pred)
@@ -63,7 +63,7 @@ def test_recall_correctness_maxdets_10(self):
6363
recall = COCORecall(
6464
category_ids=categories + [1000],
6565
max_detections=10,
66-
area_range=(0, 1e5 ** 2),
66+
area_range=(0, 1e5**2),
6767
)
6868

6969
recall.update_state(y_true, y_pred)
@@ -77,7 +77,7 @@ def test_recall_correctness_maxdets_100(self):
7777
recall = COCORecall(
7878
category_ids=categories + [1000],
7979
max_detections=100,
80-
area_range=(0, 1e5 ** 2),
80+
area_range=(0, 1e5**2),
8181
)
8282

8383
recall.update_state(y_true, y_pred)
@@ -89,7 +89,7 @@ def test_recall_correctness_small_objects(self):
8989
recall = COCORecall(
9090
category_ids=categories + [1000],
9191
max_detections=100,
92-
area_range=(0, 32 ** 2),
92+
area_range=(0, 32**2),
9393
)
9494

9595
recall.update_state(y_true, y_pred)
@@ -101,7 +101,7 @@ def test_recall_correctness_medium_objects(self):
101101
recall = COCORecall(
102102
category_ids=categories + [1000],
103103
max_detections=100,
104-
area_range=(32 ** 2, 96 ** 2),
104+
area_range=(32**2, 96**2),
105105
)
106106

107107
recall.update_state(y_true, y_pred)
@@ -113,7 +113,7 @@ def test_recall_correctness_large_objects(self):
113113
recall = COCORecall(
114114
category_ids=categories + [1000],
115115
max_detections=100,
116-
area_range=(96 ** 2, 1e5 ** 2),
116+
area_range=(96**2, 1e5**2),
117117
)
118118

119119
recall.update_state(y_true, y_pred)

keras_cv/metrics/coco/recall_test.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ def test_runs_inside_model(self):
2828
recall = COCORecall(
2929
max_detections=100,
3030
category_ids=[1],
31-
area_range=(0, 64 ** 2),
31+
area_range=(0, 64**2),
3232
)
3333

3434
# These would match if they were in the area range
35-
y_true = np.array([[[0, 0, 10, 10, 1], [5, 5, 10, 10, 1]]]).astype(
36-
np.float32
37-
)
35+
y_true = np.array([[[0, 0, 10, 10, 1], [5, 5, 10, 10, 1]]]).astype(np.float32)
3836
y_pred = np.array([[[0, 0, 10, 10, 1, 1.0], [5, 5, 10, 10, 1, 0.9]]]).astype(
3937
np.float32
4038
)
@@ -48,13 +46,11 @@ def test_recall_area_range_filtering(self):
4846
recall = COCORecall(
4947
max_detections=100,
5048
category_ids=[1],
51-
area_range=(32 ** 2, 64 ** 2),
49+
area_range=(32**2, 64**2),
5250
)
5351

5452
# These would match if they were in the area range
55-
y_true = np.array([[[0, 0, 10, 10, 1], [5, 5, 10, 10, 1]]]).astype(
56-
np.float32
57-
)
53+
y_true = np.array([[[0, 0, 10, 10, 1], [5, 5, 10, 10, 1]]]).astype(np.float32)
5854
y_pred = np.array([[[0, 0, 10, 10, 1, 1.0], [5, 5, 10, 10, 1, 0.9]]]).astype(
5955
np.float32
6056
)
@@ -64,7 +60,7 @@ def test_recall_area_range_filtering(self):
6460

6561
def test_missing_categories(self):
6662
recall = COCORecall(
67-
max_detections=100, category_ids=[1, 2, 3], area_range=(0, 1e9 ** 2)
63+
max_detections=100, category_ids=[1, 2, 3], area_range=(0, 1e9**2)
6864
)
6965
t = recall.iou_thresholds.shape[0]
7066
k = recall.category_ids.shape[0]
@@ -84,7 +80,7 @@ def test_missing_categories(self):
8480

8581
def test_recall_direct_assignment(self):
8682
recall = COCORecall(
87-
max_detections=100, category_ids=[1], area_range=(0, 1e9 ** 2)
83+
max_detections=100, category_ids=[1], area_range=(0, 1e9**2)
8884
)
8985
t = recall.iou_thresholds.shape[0]
9086
k = recall.category_ids.shape[0]
@@ -98,7 +94,7 @@ def test_recall_direct_assignment(self):
9894

9995
def test_max_detections_one_third(self):
10096
recall = COCORecall(
101-
max_detections=1, category_ids=[1], area_range=(0, 1e9 ** 2)
97+
max_detections=1, category_ids=[1], area_range=(0, 1e9**2)
10298
)
10399
y_true = np.array(
104100
[
@@ -119,7 +115,7 @@ def test_max_detections_one_third(self):
119115

120116
def test_max_detections(self):
121117
recall = COCORecall(
122-
max_detections=3, category_ids=[1], area_range=(0, 1e9 ** 2)
118+
max_detections=3, category_ids=[1], area_range=(0, 1e9**2)
123119
)
124120
y_true = np.array(
125121
[
@@ -141,7 +137,7 @@ def test_max_detections(self):
141137

142138
def test_recall_direct_assignment_one_third(self):
143139
recall = COCORecall(
144-
max_detections=100, category_ids=[1], area_range=(0, 1e9 ** 2)
140+
max_detections=100, category_ids=[1], area_range=(0, 1e9**2)
145141
)
146142
t = recall.iou_thresholds.shape[0]
147143
k = recall.category_ids.shape[0]

0 commit comments

Comments
 (0)