def make_grid(imgs, names):
    """Concat list of pictures into a single big picture, align height here."""
    # A large canvas to ensure all text clear.
    figure = create_figure(dpi=150, figsize=(16, 9))

    # deal with imgs
    max_nrows = 1
    img_shapes = []
    for img in imgs:
        if isinstance(img, list):
            max_nrows = max(len(img), max_nrows)
            img_shapes.append([i.shape[:2] for i in img])
        else:
            img_shapes.append(img.shape[:2])
    gs = figure.add_gridspec(max_nrows, len(imgs))

    for i, img in enumerate(imgs):
        if isinstance(img, list):
            for j in range(len(img)):
                subplot = figure.add_subplot(gs[j, i])
                subplot.axis(False)
                subplot.imshow(img[j])
                name = '\n'.join(textwrap.wrap(names[i] + str(j), width=20))
                subplot.set_title(
                    f'{name}\n{img_shapes[i][j]}',
                    fontsize=15,
                    family='monospace')
        else:
            subplot = figure.add_subplot(gs[:, i])
            subplot.axis(False)
            subplot.imshow(img)
            name = '\n'.join(textwrap.wrap(names[i], width=20))
            subplot.set_title(
                f'{name}\n{img_shapes[i]}', fontsize=15, family='monospace')

    # Manage the gap of subplots
    figure.tight_layout()

    # Remove the white boundary (reserve 0.5 inches at the top to show label)
    points = figure.get_tightbbox(
        figure.canvas.get_renderer()).get_points() + [[0, 0], [0, 0.5]]
    adjust_bbox(figure, transforms.Bbox(points))

    return img_from_canvas(figure.canvas)
Concat list of pictures into a single big picture, align height here.
tools/visualization/browse_dataset.py