Comments (5)
How about always returning a dictionary which contains drawn parameters.
Here is an example.
dst_img, params = random_expand(src_img)
# params: {'ratio': ***, 'x_offset': ***, 'y_offset': ***}
dst_img, params = random_crop(src_img, (***, ***))
# params: {'x_slice': ***, 'y_slice': ***}
If users do not need params, they can write
dst_img, _ = random_*(src_img, ...)
from chainercv.
I think what you proposed is simple and nice.
However, I have a concern that it is not clear as to which transforms return params.
For example, center_crop
returns params too. Also, I think ten_crop
should return it too (it does not in status quo). These parameters become helpful when users want to use center_crop
together with other data types (e.g. bounding boxes).
from chainercv.
There are three options
- making params optional for
random_*
and transforms such ascenter_crop
- params is not optional for
random_*
, but optional forcenter_crop
- params is not optional for all transforms.
from chainercv.
I think the third option is the best. In this case, all functions without computed params, such as flip
and pad
, should return empty dictionaries.
from chainercv.
Thanks for your opinion.
I think that there is still a room left on how to decide parameter convention for transforms that act on non-
image data types.
If we make those transforms to return params as well, I think that it looks redundant and in most cases unnecessary.
Instead, if we do not make those transforms to return params, it would defeat the purpose because consistency will be lost. Also, this would not work in the case when transforms on non-image need to return param
.
Considering those points, I would rather make all transforms to have optional parameter return_params
if necessary.
I compared both options in some example codes I had.
Semantic Segmentation Example (one in examples)
# prepare datasets
def transform(in_data):
img, label = in_data
vgg_subtract_bgr = np.array(
[103.939, 116.779, 123.68], np.float32)[:, None, None]
img -= vgg_subtract_bgr
img, _ = transforms.pad(img, max_size=(512, 512), bg_value=0)
label, _ = transforms.pad(label, max_size=(512, 512), bg_value=-1)
return img, label
Detection example (with no return_param)
def transform(in_data):
img, bbox = in_data
img -= np.array([103.939, 116.779, 123.68])[:, None, None]
# Resize bounding box to a shape
# with the smaller edge at least at length 600
input_shape = img.shape[1:]
img, _ = transforms.scale(img, 600)
output_shape = img.shape[1:]
bbox, _ = transforms.resize_bbox(bbox, input_shape, output_shape)
# horizontally flip
img, params = transforms.random_flip(img, x_random=True)
bbox, _ = transforms.flip_bbox(bbox, output_shape, params['x_flip'])
return img, bbox
Detection example (with return_param)
def transform(in_data):
img, bbox = in_data
img -= np.array([103.939, 116.779, 123.68])[:, None, None]
# Resize bounding box to a shape
# with the smaller edge at least at length 600
input_shape = img.shape[1:]
img = transforms.scale(img, 600)
output_shape = img.shape[1:]
bbox = transforms.resize_bbox(bbox, input_shape, output_shape)
# horizontally flip
img, param = transforms.random_flip(img, x_random=True, return_param=True)
bbox= transforms.flip_bbox(bbox, output_shape, param['x_flip'])
return img, bbox
from chainercv.
Related Issues (20)
- Faster RCNN training result problem HOT 2
- Add a img.resize function in utils HOT 2
- A function to return segmented image HOT 2
- no module named 'chainercv.datasets' HOT 6
- Problems of FCIS HOT 6
- Problem about eval_detection HOT 2
- Accuracy problems of FCIS example HOT 5
- loc_normalize_std in ProposalTargetCreator HOT 5
- yolo/train_v3.py does not work HOT 2
- DirectoryParsingLabelDataset fails to read images with an alpha channel
- Allow empty object bounding box for SSD training
- `neg_iou_thresh_lo` value in `ProposalTargetCreator`
- Is it fixed for loading the trained weights for FPN model? HOT 2
- Change Request in chainercv/examples/fpn/train_multi.py HOT 1
- build wheels for chainerCV failed HOT 1
- can't install environment, invalid channel HOT 3
- "Introduction to Chainer" doc link broken
- Request for train.py for YOLO
- eval_semantic_segmentation and calc_semantic_segmentation_confusion for when we have ignore label
- possible bug in the way that mIoU is computed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chainercv.