-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add down_sampling.py for generating LQ image from GT image. #222
Conversation
…required in LIIF.
Args: | ||
scale_min (int): The minimum of upsampling scale. Default: 1. | ||
scale_max (int): The maximum of upsampling scale. Default: 4. | ||
inp_size (int): The input size, i.e. cropped lr patch size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inp_size -> input_size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or patch_size?
|
||
Args: | ||
scale_min (int): The minimum of upsampling scale. Default: 1. | ||
scale_max (int): The maximum of upsampling scale. Default: 4. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this min to max range inclusive or exclusive
|
||
Args: | ||
results (dict): A dict containing the necessary information and | ||
data for augmentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clearly specify which keys are required, which are modified
if isinstance(size, int): | ||
size = (size, size) | ||
if isinstance(img, np.ndarray): | ||
return np.asarray(Image.fromarray(img).resize(size, Image.BICUBIC)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Will cv2.resize or mmcv.imresize work here?
- Is the PIL image a hard requirement
if isinstance(size, int): | ||
size = (size, size) | ||
if isinstance(img, np.ndarray): | ||
return np.asarray(Image.fromarray(img).resize(size, Image.BICUBIC)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Will cv2.resize or mmcv.imresize work here?
- Is the PIL image a hard requirement?
Codecov Report
@@ Coverage Diff @@
## master #222 +/- ##
==========================================
- Coverage 81.71% 81.69% -0.02%
==========================================
Files 148 149 +1
Lines 7055 7102 +47
Branches 1047 1052 +5
==========================================
+ Hits 5765 5802 +37
- Misses 1171 1179 +8
- Partials 119 121 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Scale will be in the range of [scale_min, scale_max). | ||
""" | ||
|
||
def __init__(self, scale_min=1, scale_max=4, patch_size=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add interpolation and backend here, and pass them to resize_fn
modified 'gt', supplement 'lq' and 'scale' to keys. | ||
""" | ||
img = results['gt'] | ||
scale = random.uniform(self.scale_min, self.scale_max) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use np.random
|
||
|
||
@PIPELINES.register_module() | ||
class DownSampling: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DownSampling -> RandomDownSampling
"""Generate LQ image from GT (and crop). | ||
|
||
Args: | ||
scale_min (int): The minimum of upsampling scale, inclusive. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int -> float
|
||
@PIPELINES.register_module() | ||
class DownSampling: | ||
"""Generate LQ image from GT (and crop). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Give a detailed description here. e.g. it randomly pick a scale
if isinstance(size, int): | ||
size = (size, size) | ||
if isinstance(img, np.ndarray): | ||
return imresize(img, size, interpolation='bicubic', backend='pillow') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not hardcode bicubic here
return imresize(img, size, interpolation='bicubic', backend='pillow') | ||
elif isinstance(img, torch.Tensor): | ||
image = imresize( | ||
img.numpy(), size, interpolation='bicubic', backend='pillow') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
…ab#222) * Add down_sampling.py for generating LQ image from GT image, which is required in LIIF. * Add '__repr__' and test_down_sampling.py. * Add docstring, rename parameter and change the function of resize. * Fine-tuning code and docstring of RandomDownSampling class. * Remove hardcode of bicubic and pillow. Co-authored-by: 李尹硕 <SENSETIME\[email protected]>
Add down_sampling.py for generating LQ image from GT image, which is required in Learning Continuous Image Representation with Local Implicit Image Function