eanet's People
Forkers
strongdiamondeanet's Issues
loss
Hi! I use your project to train my own dataset,but my miou is nan.And loss is almost unchanged after dropping to 2.8 .
Any help will be appreciated !Thank you
Edge loss didn't converge
Hi @geovsion ,
I just added edge loss (EdgeLoss module) in your code to the original cross entropy loss of a semantic segmentation network (DDCM-Net) , then trained the network on the ISPRS Vaihingen and Potsdam dataset, but the edge loss part didn't converge and kept oscillating like this:
I visualize the edge map in the forward method of EdgeLoss module as follows:
`def forward(self, logits, label):
prediction = F.softmax(logits, dim=1)
edge_maps = []
# kernel size of Laplace filter
ks = 2 * self.radius
filt1 = torch.ones(1, 1, ks, ks)
filt1[:, :, self.radius:2self.radius, self.radius:2self.radius] = -8
filt1.requires_grad = False
filt1 = filt1.cuda()
label = label.unsqueeze(1)
# apply 2D convolution over label using filt1 (Laplacian filter) to get label edge map
lbedge = F.conv2d(label.float(), filt1, bias=None, stride=1, padding=self.radius)
lbedge = 1 - torch.eq(lbedge, 0).float()
filt2 = torch.ones(self.n_classes, 1, ks, ks)
filt2[:, :, self.radius:2*self.radius, self.radius:2*self.radius] = -8
filt2.requires_grad = False
filt2 = filt2.cuda()
# get edge map of prediction
prededge = F.conv2d(prediction.float(), filt2, bias=None,
stride=1, padding=self.radius, groups=self.n_classes)
# squash C-dimensional (C is n_classes) edge map to single edge map
norm = torch.sum(torch.pow(prededge,2), 1).unsqueeze(1)
prededge = norm/(norm + self.alpha)
# mask = lbedge.float()
# num_positive = torch.sum((mask==1).float()).float()
# num_negative = torch.sum((mask==0).float()).float()
# mask[mask == 1] = 1.0 * num_negative / (num_positive + num_negative)
# mask[mask == 0] = 1.5 * num_positive / (num_positive + num_negative)
# cost = torch.nn.functional.binary_cross_entropy(
# prededge.float(),lbedge.float(), weight=mask, reduce=False)
# return torch.mean(cost)
# visualize edge maps
edge_maps.append(prededge.float())
edge_maps.append(lbedge.float())
edge_maps = torch.cat(edge_maps, dim=0)
edge_maps_grid = torchvision.utils.make_grid(edge_maps, nrow=prededge.size(0))
plt.imshow(edge_maps_grid.permute(1, 2, 0).detach().cpu(), cmap='gray')
plt.title('Edge maps of 1-channel pred and gt')
plt.show()
return BinaryDiceLoss()(prededge.float(),lbedge.float())`
The visualized result on the Vaihingen dataset is like this:
The optimizer is Adam with AMSGrad. May you help me find the reason? Thanks!
Environment
Hi! I want to know what is your pytorch version.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.