bigmb / Unet-Segmentation-Pytorch-Nest-of-Unets

Implementation of different kinds of Unet Models for Image Segmentation - Unet , RCNN-Unet, Attention Unet, RCNN-Attention Unet, Nested Unet
MIT License
1.87k stars 345 forks source link

Visualization issue #2

Closed LinYangKorea closed 5 years ago

LinYangKorea commented 5 years ago

` def plot_kernels(tensor, n_iter, num_cols=5, cmap="gray"): """Plotting the kernals and layers Args: Tensor :Input layer, n_iter : number of interation, num_cols : number of columbs required for figure Output: Gives the figure of the size decided with output layers activation map

Default : Last layer will be taken into consideration
    """
if not len(tensor.shape) == 4:
    raise Exception("assumes a 4D tensor")

fig = plt.figure()
i = 0
t = tensor.data.numpy()
b = 0
a = 1

for t1 in t:
    for t2 in t1:
        i += 1

        ax1 = fig.add_subplot(5, num_cols, i)
        ax1.imshow(t2, cmap=cmap)
        ax1.axis('off')
        ax1.set_xticklabels([])
        ax1.set_yticklabels([])

        if i == 1:
            a = 1
        if a == 10:
            break
        a += 1
    if i % a == 0:
        a = 0
    b += 1
    if b == 20:
        break

plt.savefig(
    './model/pred/Kernal_' + str(n_iter - 1) + '_epoch_'
    + str(i))`

Why is all these data added. It stops when I try to change something here.

bigmb commented 5 years ago

Hello Lin,

If you try to plot all the filters used in convolution for any layer it will take up a lot of time and hangs the compiler. I have added this when I was testing it, but if you use the one in Pytorch_run.py file, then you will just get the last layer output which will be a single image.

Let me know if you have any other issue.

bigmb commented 5 years ago

Closing this Issue, if you have any doubts let me know. Will update all files soon with comments.