Beispiel #1
0
def show_batch(
    x: AudioTensor,
    y,
    samples,
    ctxs=None,
    max_n=6,
    nrows=2,
    ncols=1,
    figsize=None,
    **kwargs,
):
    if figsize is None:
        figsize = (4 * x.nchannels, 6)

    if ctxs is None:
        ctxs = get_grid(min(len(samples), max_n),
                        nrows=nrows,
                        ncols=ncols,
                        figsize=figsize)
    ctxs = show_batch[object](x,
                              y,
                              samples,
                              ctxs=ctxs,
                              max_n=max_n,
                              hear=False,
                              **kwargs)
    return ctxs
Beispiel #2
0
def show_results(x: TensorTS,
                 y,
                 samples,
                 outs,
                 ctxs=None,
                 max_n=9,
                 nrows=None,
                 ncols=None,
                 figsize=(14, 12),
                 **kwargs):
    if ctxs is None:
        ctxs = get_grid(min(len(samples), max_n),
                        nrows=nrows,
                        ncols=ncols,
                        add_vert=1,
                        figsize=figsize)
    # outs = [('6.0',),('2.0',)]
    outs = [detuplify(o) for o in outs]
    # outs = ['6.0', '2.0']

    ctxs = default_show_results(x,
                                y,
                                samples,
                                outs,
                                ctxs=ctxs,
                                max_n=max_n,
                                figsize=figsize,
                                **kwargs)
    return ctxs
def plot_images(images):
    n = len(images)
    axs = get_grid(n, figsize=(12,9))
    for ax, im in zip(axs, images):
        if im.shape[0]==1:
            im = rearrange(im, 'c h w -> h w c')
            ax.imshow(im)
        elif im.shape[0]==3:
            im = rearrange(im, 'c h w -> h w c')
            ax.imshow(im)
        else:
            ax.imshow(im)
        ax.axis('off')
    plt.show()
Beispiel #4
0
def show_batch(x: TensorTS,
               y,
               samples,
               ctxs=None,
               max_n=9,
               nrows=None,
               ncols=None,
               figsize=(14, 12),
               **kwargs):
    if ctxs is None:
        ctxs = get_grid(min(len(samples), max_n),
                        nrows=nrows,
                        ncols=ncols,
                        figsize=figsize)
    ctxs = default_show_batch(x, y, samples, ctxs=ctxs, max_n=max_n, **kwargs)
    return ctxs
Beispiel #5
0
def show_batch(x: PTBImage,
               y,
               samples,
               ctxs=None,
               max_n=6,
               nrows=None,
               ncols=2,
               figsize=None,
               **kwargs):
    if figsize is None: figsize = (ncols * 6, max_n // ncols * 3)
    if ctxs is None:
        ctxs = get_grid(min(x[0].shape[0], max_n),
                        nrows=None,
                        ncols=ncols,
                        figsize=figsize)
        type(x)
        type(x[0])
        for i, ctx in enumerate(ctxs):
            PTBImage((x[0][i], x[1][i])).show(ctx=ctx)
Beispiel #6
0
def show_batch(x: TSeries,
               y,
               samples,
               ctxs=None,
               max_n=10,
               rows=None,
               cols=None,
               figsize=None,
               **kwargs):
    "Show batch for TSeries objects"
    if ctxs is None:
        ctxs = get_grid(min(len(samples), max_n),
                        nrows=rows,
                        ncols=cols,
                        add_vert=1,
                        figsize=figsize)
    ctxs = show_batch[object](x,
                              y,
                              samples=samples,
                              ctxs=ctxs,
                              max_n=max_n,
                              **kwargs)
    return ctxs