Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Add tile_images #422

Merged
merged 10 commits into from
Oct 5, 2017
Merged

Add tile_images #422

merged 10 commits into from
Oct 5, 2017

Conversation

yuyu2172
Copy link
Member

@yuyu2172 yuyu2172 commented Sep 14, 2017

Merge after #421

from chainercv.visualizations import vis_image
from chainercv.datasets import VOCSemanticSegmentationDataset
from chainercv.utils import make_grid
import matplotlib.pyplot as plt
from chainercv.transforms import center_crop
import numpy as np

dataset = VOCSemanticSegmentationDataset()
imgs = np.array([center_crop(data[0], (224, 224)) for data in dataset[:10]])
grid = make_grid(imgs, n_col=3, pad=3)
vis_image(grid)
plt.show()

Output (with pad=3)
figure_1-3

Output (with pad=50)
figure_1-4

@yuyu2172 yuyu2172 changed the title Make grid Add make_grid Sep 14, 2017
@Hakuyume
Copy link
Member

How about tile_images? make_grid sounds ambiguous.

@yuyu2172
Copy link
Member Author

OK

@yuyu2172 yuyu2172 changed the title Add make_grid Add tile_images Sep 14, 2017
@@ -5,6 +5,7 @@
from chainercv.utils.download import extractall # NOQA
from chainercv.utils.image import read_image # NOQA
from chainercv.utils.image import write_image # NOQA
from chainercv.utils.image.tile_images import tile_images # NOQA
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from chainercv.utils.image import tile_images

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tile_images comes before write_image in alphabetical order.

for x in range(n_col):
if k >= B:
break
start_y = y * (H + pad) + pad // 2 + 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you add 1? In the case that pad == 0, the top-left corner of the first image will be (1, 1) although it should be (0, 0).


Returns:
~numpy.ndarray:
An image array in CHW format.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding a note about the output size?
The size of this image is :math:((H + pad) * \lceil B / n_col \rceil, (W + pad) * n_col)


Args:
imgs (numpy.ndarray): A batch of images whose shape is BCHW.
n_col (int): Number of columns in a tile.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number? (I found both Number of and The number of in our code)


@testing.parameterize(*testing.product({
'fill': [128, (104, 117, 123), np.random.uniform(255, size=(3, 1, 1))],
'pad': [1, 2, 3]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about testing the case pad = 0? With this test, this bug can be found.

@yuyu2172 yuyu2172 added this to the v0.7 milestone Sep 20, 2017
Copy link
Member

@Hakuyume Hakuyume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Hakuyume Hakuyume merged commit 2182d93 into chainer:master Oct 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants