diff --git a/official/cv/faster_rcnn/src/dataset.py b/official/cv/faster_rcnn/src/dataset.py
index 655a051c5a40da49117b836188fcd1f5c9cc2df8..39008f356666d6c388a070bd9bff2ebeb1196773 100644
--- a/official/cv/faster_rcnn/src/dataset.py
+++ b/official/cv/faster_rcnn/src/dataset.py
@@ -219,9 +219,9 @@ def rescale_column_test(img, img_shape, gt_bboxes, gt_label, gt_num, config):
 def resize_column(img, img_shape, gt_bboxes, gt_label, gt_num, config):
     """resize operation for image"""
     img_data = img
+    h, w = img_data.shape[:2]
     img_data = cv2.resize(
         img_data, (config.img_width, config.img_height), interpolation=cv2.INTER_LINEAR)
-    h, w = img_data.shape[:2]
     h_scale = config.img_height / h
     w_scale = config.img_width / w
 
@@ -241,9 +241,9 @@ def resize_column(img, img_shape, gt_bboxes, gt_label, gt_num, config):
 def resize_column_test(img, img_shape, gt_bboxes, gt_label, gt_num, config):
     """resize operation for image of eval"""
     img_data = img
+    h, w = img_data.shape[:2]
     img_data = cv2.resize(
         img_data, (config.img_width, config.img_height), interpolation=cv2.INTER_LINEAR)
-    h, w = img_data.shape[:2]
     h_scale = config.img_height / h
     w_scale = config.img_width / w
 
diff --git a/official/cv/maskrcnn/src/dataset.py b/official/cv/maskrcnn/src/dataset.py
index 49ed6700b625f7611f89f9dc23ea2166ebce86d0..38a7fa50960355177b76170f6655ba9e0152111f 100644
--- a/official/cv/maskrcnn/src/dataset.py
+++ b/official/cv/maskrcnn/src/dataset.py
@@ -229,8 +229,8 @@ def rescale_column_test(img, img_shape, gt_bboxes, gt_label, gt_num, gt_mask):
 def resize_column(img, img_shape, gt_bboxes, gt_label, gt_num, gt_mask):
     """resize operation for image"""
     img_data = img
-    img_data = cv2.resize(img_data, (config.img_width, config.img_height), interpolation=cv2.INTER_LINEAR)
     h, w = img_data.shape[:2]
+    img_data = cv2.resize(img_data, (config.img_width, config.img_height), interpolation=cv2.INTER_LINEAR)
     h_scale = config.img_height / h
     w_scale = config.img_width / w
 
@@ -252,8 +252,8 @@ def resize_column(img, img_shape, gt_bboxes, gt_label, gt_num, gt_mask):
 def resize_column_test(img, img_shape, gt_bboxes, gt_label, gt_num, gt_mask):
     """resize operation for image of eval"""
     img_data = img
-    img_data = cv2.resize(img_data, (config.img_width, config.img_height), interpolation=cv2.INTER_LINEAR)
     h, w = img_data.shape[:2]
+    img_data = cv2.resize(img_data, (config.img_width, config.img_height), interpolation=cv2.INTER_LINEAR)
     h_scale = config.img_height / h
     w_scale = config.img_width / w
 
diff --git a/official/cv/maskrcnn_mobilenetv1/src/dataset.py b/official/cv/maskrcnn_mobilenetv1/src/dataset.py
index 7813377b089504a5cb55f291c0bd9d9b29cef4e0..e8ea04752a69303f992e85862099c95f50dd74d1 100644
--- a/official/cv/maskrcnn_mobilenetv1/src/dataset.py
+++ b/official/cv/maskrcnn_mobilenetv1/src/dataset.py
@@ -242,9 +242,9 @@ def rescale_column_test(img, img_shape, gt_bboxes, gt_label, gt_num, gt_mask):
 def resize_column(img, img_shape, gt_bboxes, gt_label, gt_num, gt_mask):
     """resize operation for image"""
     img_data = img
+    h, w = img_data.shape[:2]
     img_data = cv2.resize(
         img_data, (config.img_width, config.img_height), interpolation=cv2.INTER_LINEAR)
-    h, w = img_data.shape[:2]
     h_scale = config.img_height / h
     w_scale = config.img_width / w
 
@@ -266,9 +266,9 @@ def resize_column(img, img_shape, gt_bboxes, gt_label, gt_num, gt_mask):
 def resize_column_test(img, img_shape, gt_bboxes, gt_label, gt_num, gt_mask):
     """resize operation for image of eval"""
     img_data = img
+    h, w = img_data.shape[:2]
     img_data = cv2.resize(
         img_data, (config.img_width, config.img_height), interpolation=cv2.INTER_LINEAR)
-    h, w = img_data.shape[:2]
     h_scale = config.img_height / h
     w_scale = config.img_width / w