"src/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "a1f36ee3ef4ae1bf98bd260e539197259aa981c1"
Unverified Commit 629ef89c authored by Zaida Zhou's avatar Zaida Zhou Committed by GitHub
Browse files

Pick commits from 2.x branch (#2284)



* [Fix] Fix the calculation error of out_w in MaskedConv2dFunction (#2264)

* [Fix] Fix two intergers can not use / operator in torch1.6

* should not use kernel_h when calculates out_w

* [Docs] Fix some mistakes in data_process.md (#2283)

* correction

* correction en docs
Co-authored-by: default avataryxzhao <33384732+yxzhao2022@users.noreply.github.com>
parent 3b9b9054
...@@ -135,7 +135,7 @@ bboxes = np.array([[10, 10, 100, 120], [0, 0, 50, 50]]) ...@@ -135,7 +135,7 @@ bboxes = np.array([[10, 10, 100, 120], [0, 0, 50, 50]])
patches = mmcv.imcrop(img, bboxes) patches = mmcv.imcrop(img, bboxes)
# crop two regions, and rescale the patches by 1.2x # crop two regions, and rescale the patches by 1.2x
patches = mmcv.imcrop(img, bboxes, scale_ratio=1.2) patches = mmcv.imcrop(img, bboxes, scale=1.2)
``` ```
#### Padding #### Padding
...@@ -150,14 +150,14 @@ img = mmcv.imread('tests/data/color.jpg') ...@@ -150,14 +150,14 @@ img = mmcv.imread('tests/data/color.jpg')
img_ = mmcv.impad(img, shape=(1000, 1200), pad_val=0) img_ = mmcv.impad(img, shape=(1000, 1200), pad_val=0)
# pad the image to (1000, 1200) with different values for three channels. # pad the image to (1000, 1200) with different values for three channels.
img_ = mmcv.impad(img, shape=(1000, 1200), pad_val=[100, 50, 200]) img_ = mmcv.impad(img, shape=(1000, 1200), pad_val=(100, 50, 200))
# pad the image on left, right, top, bottom borders with all zeros # pad the image on left, right, top, bottom borders with all zeros
img_ = mmcv.impad(img, padding=(10, 20, 30, 40), pad_val=0) img_ = mmcv.impad(img, padding=(10, 20, 30, 40), pad_val=0)
# pad the image on left, right, top, bottom borders with different values # pad the image on left, right, top, bottom borders with different values
# for three channels. # for three channels.
img_ = mmcv.impad(img, padding=(10, 20, 30, 40), pad_val=[100, 50, 200]) img_ = mmcv.impad(img, padding=(10, 20, 30, 40), pad_val=(100, 50, 200))
# pad an image so that each edge is a multiple of some value. # pad an image so that each edge is a multiple of some value.
img_ = mmcv.impad_to_multiple(img, 32) img_ = mmcv.impad_to_multiple(img, 32)
......
...@@ -130,7 +130,7 @@ bboxes = np.array([[10, 10, 100, 120], [0, 0, 50, 50]]) ...@@ -130,7 +130,7 @@ bboxes = np.array([[10, 10, 100, 120], [0, 0, 50, 50]])
patches = mmcv.imcrop(img, bboxes) patches = mmcv.imcrop(img, bboxes)
# 裁剪两个区域并且缩放区域1.2倍 # 裁剪两个区域并且缩放区域1.2倍
patches = mmcv.imcrop(img, bboxes, scale_ratio=1.2) patches = mmcv.imcrop(img, bboxes, scale=1.2)
``` ```
#### 填充 #### 填充
...@@ -144,13 +144,13 @@ img = mmcv.imread('tests/data/color.jpg') ...@@ -144,13 +144,13 @@ img = mmcv.imread('tests/data/color.jpg')
img_ = mmcv.impad(img, shape=(1000, 1200), pad_val=0) img_ = mmcv.impad(img, shape=(1000, 1200), pad_val=0)
# 用给定值分别填充图像的3个通道至 (1000, 1200) # 用给定值分别填充图像的3个通道至 (1000, 1200)
img_ = mmcv.impad(img, shape=(1000, 1200), pad_val=[100, 50, 200]) img_ = mmcv.impad(img, shape=(1000, 1200), pad_val=(100, 50, 200))
# 用给定值填充图像的左、右、上、下四条边 # 用给定值填充图像的左、右、上、下四条边
img_ = mmcv.impad(img, padding=(10, 20, 30, 40), pad_val=0) img_ = mmcv.impad(img, padding=(10, 20, 30, 40), pad_val=0)
# 用3个值分别填充图像的左、右、上、下四条边的3个通道 # 用3个值分别填充图像的左、右、上、下四条边的3个通道
img_ = mmcv.impad(img, padding=(10, 20, 30, 40), pad_val=[100, 50, 200]) img_ = mmcv.impad(img, padding=(10, 20, 30, 40), pad_val=(100, 50, 200))
# 将图像的四条边填充至能够被给定值整除 # 将图像的四条边填充至能够被给定值整除
img_ = mmcv.impad_to_multiple(img, 32) img_ = mmcv.impad_to_multiple(img, 32)
......
...@@ -47,11 +47,13 @@ class MaskedConv2dFunction(Function): ...@@ -47,11 +47,13 @@ class MaskedConv2dFunction(Function):
batch_size = features.size(0) batch_size = features.size(0)
out_h = int( out_h = int(
math.floor((features.size(2) + 2 * pad_h - math.floor(
(kernel_h - 1) - 1) / stride_h + 1)) torch.true_divide((features.size(2) + 2 * pad_h -
(kernel_h - 1) - 1), stride_h) + 1))
out_w = int( out_w = int(
math.floor((features.size(3) + 2 * pad_w - math.floor(
(kernel_h - 1) - 1) / stride_w + 1)) torch.true_divide((features.size(3) + 2 * pad_w -
(kernel_w - 1) - 1), stride_w) + 1))
mask_inds = torch.nonzero(mask[0] > 0, as_tuple=False) mask_inds = torch.nonzero(mask[0] > 0, as_tuple=False)
output = features.new_zeros(batch_size, out_channel, out_h, out_w) output = features.new_zeros(batch_size, out_channel, out_h, out_w)
if mask_inds.numel() > 0: if mask_inds.numel() > 0:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment