Giter Site home page Giter Site logo

gurupradeep / fcn-for-semantic-segmentation Goto Github PK

View Code? Open in Web Editor NEW
175.0 8.0 78.0 16.6 MB

Implemention of FCN-8 and FCN-16 with Keras and uses CRF as post processing

License: MIT License

Jupyter Notebook 100.00%
semantic-segmentation fcn crf vgg16

fcn-for-semantic-segmentation's People

Contributors

gurupradeep avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fcn-for-semantic-segmentation's Issues

pascal-fcn16s-dag.mat

Hello,can you tell me how i can get the pascal-fcn16s-dag.mat which is used in fcn_16.ipynb

Where is the weights.h5 file?

I tried running your code but I always come across an error that says weights.h5 cannot be found. I downloaded another weights file, but using that shows another error saying "you are trying to load a 0 layer model into a 19 layer model". Upon further digging I found out that this has something to do with the version of keras being used.

So my questions are:

  1. Where is the weights.h5 file?
  2. If I can't get that file, what is the version of keras you used to build this project?

Thank you

Why do I use CRF code to come out like this?

Hello, Thanks for sharing the code. But I have a question, why do I use the CRF code to come out like this?

image

PS: My train image data is three channel image. And my prediction image is already colored three-channel image data. I used the CRF function to pass in the original image, the colored image and the output image, I don't know if it's a mistake?

pydensecrf package problem

I want to use CRF.ipynb to post processing, I got an issue: module 'pydensecrf.densecrf' has no attribute 'DenseCRF2D'.
(before that :pip install pydensecrf)

Coarse output from the network

Hello, thanks for your work, I have tried to rewrite your network using PyTorch, but what I got from the network is a coarse image where I can only see the profile of my segmentation object, would you like to tell me where I was wrong, thanks!

my model code is like this:

import torchvision.models as models
import torch.nn as nn
import torch.nn.functional as F

# referred to this site: https://github.com/Gurupradeep/FCN-for-Semantic-Segmentation
class MyFCN(nn.Module):
    def __init__(self):
        super().__init__()
        model = models.vgg16(pretrained=True)
        self.backbone_third = model.features[:17]  # (256, 28, 28) third pooling before conv layer
        self.backbone_fourth = model.features[:24] # (512, 14, 14) fourth pooling before conv layer
        self.backbone_fifth = model.features[:31]  # (512, 7, 7) final pooling before conv layer

        self.conv_256_1 = nn.Sequential(
            nn.Conv2d(256, 1, (1, 1), 1),
        )

        self.conv_512_1 = nn.Sequential(
            nn.Conv2d(512, 1, (1, 1), 1),
        )

        # fc6
        self.conv_512_4096 = nn.Sequential(
            nn.Conv2d(512, 4096, (7, 7), 1, 3),
            nn.ReLU(inplace=True),
        )

        # fc7
        self.conv_4096_4096 = nn.Sequential(
            nn.Conv2d(4096, 4096, (1, 1), 1),
            nn.ReLU(inplace=True),
        )

        # score_fr
        self.conv_4096_1 = nn.Sequential(
            nn.Conv2d(4096, 1, (1, 1), 1),
            nn.ReLU(inplace=True),
        )

        # score_2 for 7=>14 and 14=>28
        self.conv_transpose = nn.Sequential(
            nn.ConvTranspose2d(1, 1, (4, 4), 2),
        )

        # final upsample
        self.conv_transpose_8 = nn.Sequential(
            nn.ConvTranspose2d(1, 1, (16, 16), 8),
        )


    def forward(self, x):
        x_from_pooling_3 = self.backbone_third(x)
        x_from_pooling_4 = self.backbone_fourth(x)
        x_from_pooling_5 = self.backbone_fifth(x)

        # pooling 3
        x_3 = self.conv_256_1(x_from_pooling_3)

        # pooling 4
        x_4 = self.conv_512_1(x_from_pooling_4)     # (1, 1, 14, 14)

        # pooling 5
        x_5 = self.conv_512_4096(x_from_pooling_5)  # (1, 4096, 7, 7)
        x_5 = self.conv_4096_4096(x_5)              # (1, 4096, 7, 7)
        x_5 = self.conv_4096_1(x_5)                 # (1, 1, 7, 7)
        x_5 = self.conv_transpose(x_5)              # (1, 1, 16, 16)
        x_5 = F.pad(x_5, (-1, -1, -1, -1))          # crop layer, (1, 1, 14, 14)

        # fusing x_4
        x_fused_1 = x_4 + x_5                       # (1, 1, 14, 14)
        x_fused_1 = self.conv_transpose(x_fused_1)  # (1, 1, 30, 30)
        x_fused_1 = F.pad(x_fused_1, (-1, -1, -1, -1))  # crop layer, (1, 1, 28, 28)

        # fusing x_3
        x_fused_2 = x_3 + x_fused_1
        x_fused_2 = self.conv_transpose_8(x_fused_2)    # (1, 1, 232, 232)
        x_fused_2 = F.pad(x_fused_2, (-4, -4, -4, -4))  # crop layer (1, 1, 224, 224)

        return x_fused_2

and my output is like:
epoch_17

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.