Giter VIP home page Giter VIP logo

Comments (7)

khdlr avatar khdlr commented on July 20, 2024

Kindly refer to Fig. 3 in the paper (https://arxiv.org/pdf/2103.01849.pdf). The attention is not in the channel dimension, but in the "resolution" dimension. There is only one query (the output), and one key/value for each resolution level.

In order to use it for your segmentation project, you're going to need to adapt data_loading.py for your own dataset and then simply call python train.py.

from hed-unet.

VoyageWang avatar VoyageWang commented on July 20, 2024

from hed-unet.

VoyageWang avatar VoyageWang commented on July 20, 2024

Thanks for your reply! I had met another question about how to visualize the effective receptive field like fig9 in the article. Can you show me the code? This can help me a lot. Thanks again!

from hed-unet.

khdlr avatar khdlr commented on July 20, 2024

The general idea is to backpropagate the output of a central pixel, and average that over your validation dataset:

erfs = []

for img, mask in val_loader:
  img = img.to(device)
  img.requires_grad = True
  out = model(img)
  _, _, H, W = out.shape
  center = out[:, :, H//2, W//2].mean()
  center.backward()
  erfs.append(img.grad.abs().mean(dim=[1,2]))

erf = torch.mean(torch.stack(erfs, dim=0), dim=0)

Written from memory - I am not on the server to double-check the accuracy of the above code. Let me know if you have any additional questions.

from hed-unet.

VoyageWang avatar VoyageWang commented on July 20, 2024

Thanks for your reply! I got this idea and understood the idea of ERF after your teaching. I have another question about how to get the figure of edge like fig 5. In other words, how to detect the edge from the segmentation results? Can you show me the code?

from hed-unet.

khdlr avatar khdlr commented on July 20, 2024

The model directly generates an edge detection map, there is no need to derive the edges from the segmentation results. I.e. model(inputs)[batch_idx, 0] will be the segmentation prediction and model(inputs)[batch_idx, 1] is the edge prediction.

The function used for the plots in fig. 5 is literally the first function in train.py:

def showexample(idx, img, target, prediction):

from hed-unet.

VoyageWang avatar VoyageWang commented on July 20, 2024

from hed-unet.

Related Issues (18)

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.