JitteredResize
類別keras_cv.layers.JitteredResize(
target_size,
scale_factor,
crop_size=None,
bounding_box_format=None,
interpolation="bilinear",
seed=None,
**kwargs
)
JitteredResize 透過縮放扭曲實現調整大小。
JitteredResize 採用三步驟方法進行基於大小扭曲的圖像增強。此技術專為目標檢測管道進行調整。該圖層接收圖像和邊界框作為輸入,兩者都可能是參差不齊的。它輸出一個密集的圖像張量,準備好輸入模型進行訓練。因此,此圖層通常是增強管道中的最後一步。
增強過程如下
首先根據隨機採樣的縮放因子縮放圖像。然後根據採樣的縮放比例調整圖像的寬度和高度。這樣做是為了將噪聲引入圖像中特徵的局部尺度。然後根據 crop_size
隨機裁剪圖像的子集。然後將此裁剪填充為 target_size
。邊界框根據隨機縮放和隨機裁剪進行平移和縮放。
參數
keras_cv.FactorSampler
。對於每個增強的圖像,從提供的範圍中採樣一個值。此因子用於縮放輸入圖像。要複製 MaskRCNN 論文的結果,請傳遞 (0.8, 1.25)
。target_size
。"bilinear"
。支援 "bilinear"
、"nearest"
、"bicubic"
、"area"
、"lanczos3"
、"lanczos5"
、"gaussian"
、"mitchellcubic"
。範例
train_ds = load_object_detection_dataset()
jittered_resize = layers.JitteredResize(
target_size=(640, 640),
scale_factor=(0.8, 1.25),
bounding_box_format="xywh",
)
train_ds = train_ds.map(
jittered_resize, num_parallel_calls=tf.data.AUTOTUNE
)
# images now are (640, 640, 3)
# an example using crop size
train_ds = load_object_detection_dataset()
jittered_resize = layers.JitteredResize(
target_size=(640, 640),
crop_size=(250, 250),
scale_factor=(0.8, 1.25),
bounding_box_format="xywh",
)
train_ds = train_ds.map(
jittered_resize, num_parallel_calls=tf.data.AUTOTUNE
)
# images now are (640, 640, 3), but they were resized from a 250x250 crop.