Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use np.random instead of random #213

Merged
merged 3 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions mmedit/datasets/pipelines/augmentation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import math
import numbers
import os.path as osp
import random

import cv2
import mmcv
Expand Down Expand Up @@ -611,7 +610,7 @@ def __init__(self, keys, binary_thr=0., kernel_min=9, kernel_max=49):
self.binary_thr = binary_thr

def _random_dilate(self, img):
kernel_size = random.randint(self.kernel_min, self.kernel_max)
kernel_size = np.random.randint(self.kernel_min, self.kernel_max + 1)
kernel = np.ones((kernel_size, kernel_size), dtype=np.uint8)
dilate_kernel_size = kernel_size
img_ = cv2.dilate(img, kernel, iterations=1)
Expand Down
6 changes: 2 additions & 4 deletions mmedit/datasets/pipelines/crop.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import random

import mmcv
import numpy as np
from torch.nn.modules.utils import _pair
Expand Down Expand Up @@ -214,8 +212,8 @@ def __call__(self, results):
f'{results["lq_path"][0]} and {results["gt_path"][0]}.')

# randomly choose top and left coordinates for lq patch
top = random.randint(0, h_lq - lq_patch_size)
left = random.randint(0, w_lq - lq_patch_size)
top = np.random.randint(h_lq - lq_patch_size + 1)
left = np.random.randint(w_lq - lq_patch_size + 1)
# crop lq patch
results['lq'] = [
v[top:top + lq_patch_size, left:left + lq_patch_size, ...]
Expand Down