-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[Feature] Add Rgb2Gray transform #227
Conversation
Codecov Report
@@ Coverage Diff @@
## master #227 +/- ##
==========================================
+ Coverage 84.26% 84.35% +0.09%
==========================================
Files 90 90
Lines 4315 4340 +25
Branches 684 687 +3
==========================================
+ Hits 3636 3661 +25
Misses 537 537
Partials 142 142
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
# print(results) | ||
print(results, results['img'].shape) |
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.
Delete these.
|
||
This transform calculate the weighted mean of input image channels with | ||
``weights`` and then expand the channels to ``out_channels``. When | ||
``out_channels`` equals 0, the number of output channels is the same as |
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 None
instead of 0.
@@ -463,6 +465,61 @@ def __repr__(self): | |||
return self.__class__.__name__ + f'(crop_size={self.crop_size})' | |||
|
|||
|
|||
@PIPELINES.register_module() | |||
class Rgb2Gray(object): |
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.
RGB2Gray
Default: (0.299, 0.587, 0.114). | ||
""" | ||
|
||
def __init__(self, out_channels, weights=(0.299, 0.587, 0.114)): |
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.
Why using weighted sum instead of direct mmcv.rgb2gray
.
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.
By this method, we can use the weights defined by us instead of fixed weights.
assert len(img.shape) == 3 | ||
assert img.shape[2] == len(self.weights) | ||
weights = np.array(self.weights).reshape((1, 1, -1)) | ||
img = (img * weights).sum(2) |
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.
We may use keep_dim=True
. In this way, we don't need to expand dim.
Task linked: CU-fjrgpn Data preprocessing |
* add transformer Rgb2Gray * restore * fix self.weights * restore * fix code * restore * fix syntax error * restore
…ab#227) add add_noise method in more schedulers
wipe out the extra gpu memony cost by set the default map_location as 'cpu'
* init commit * fix download annotations * parse hvu tags * add downloading & trimming scripts * add file list generation * finish hvu datatools * resolve comments * init commit * fix download annotations * parse hvu tags * add downloading & trimming scripts * add file list generation * finish hvu datatools * resolve comments * update changelog * Update data_preparation.md Co-authored-by: Jintao Lin <528557675@qq.com>
No description provided.