cardwing / codes-for-intra-kd Goto Github PK
View Code? Open in Web Editor NEWInter-Region Affinity Distillation for Road Marking Segmentation (CVPR 2020)
License: MIT License
Inter-Region Affinity Distillation for Road Marking Segmentation (CVPR 2020)
License: MIT License
I followed the repo and download the pretrained model to test the test-subset of apollo. However, the test set have not labels while in your voc_aug_test.py, it has to contains labels for data samplers which caused the test srcipt can not run.
what should i do to remove the labels without inference or how can i run with the test srcipt.
Thanks a lot and looking forward.
When I run train_xxx.py in Windows, those Error occur:
ImportError:_ No module named 'models.sync_bn._ext.sync_bn_lib._sync_bn_lib'
This error in line ._sync_bn_lib import lib as _lib, ffi as _ffi
In Windows, python can not use .so document?
I tried to run build.py but failed.
What should I do?
Environment:
Windows10
Python 3.5
torch 0.3.0
torchvision 0.1.9
When I run train_xxx.py in Windows, those Error occur:
ImportError:_ No module named 'models.sync_bn._ext.sync_bn_lib._sync_bn_lib'
This error in line ._sync_bn_lib import lib as _lib, ffi as _ffi
In Windows, python can not use .so document?
I tried to run build.py but failed.
What should I do?
Environment:
Windows10
Python 3.5
torch 0.3.0
torchvision 0.1.9
The F1-measure of ERFNet on your paper is 70.2, but on ERFNet-CULane-PyTorch it is 73.1, even better than it with IntRA-KD.
What's the difference between them?
The mean of moment pooling is whether to calculate the moment of single-channel or the moment of each region by the label mask? Can you offer the code for this section? Thank you very much.
I read your paper, but l am not sure where and which layer or layers to be embedded into a KD?
Hi, thank you for your codes.when I run the sh test sh test_pspnet_multi_scale.sh, A problem that "Import Error: libpython3.5m.so.1.0:cannot open shared object file:No such file or directory“ occured, could you help me to solve it? In that case, I would appreciate it.
Thanks for sharing your latest algorithm!
But I am confused about table 3 in your paper. The F1 measure of ERFNet is only 70.2, which is much lower than 73.1 as previously reported here:
https://github.com/cardwing/Codes-for-Lane-Detection
Why is there such an inconsistency?
Do you have a plan to update pytorch version? Current version 0.3.0 is too old.
My pytorch version is 1.5.0 and gets the following error:
File "/home/test/anaconda3/envs/dl/lib/python3.7/site-packages/torch/utils/ffi/init.py", line 1, in
raise ImportError("torch.utils.ffi is deprecated. Please use cpp extensions instead.")
ImportError: torch.utils.ffi is deprecated. Please use cpp extensions instead.
Googling around and it says there is no easy way to get around this issue
Thanks,
When you do ERFNet-SAD, can you tell me exactly which layer learns from which?
I've tried to implement ERFNet-SAD but can't find a way at it, at the moment.
cc @cardwing
I'm might have talked about doing ERFNet-SAD in your other repo, but I can't remember where... So I opened a new one here.
Thank you for your work! We tested the pretrained model with our own collected data, but found that road markings are difficult to be detected. How can we improve the generalization of the network?
The example codes of IntRA-KD are given as follows. The following implementation is slightly different from the original paper and may cause numerical instability in some cases. You may need to carefully select the value of several hyperparameters so that IntRA-KD can work normally. If you have limited time and resources, you can just follow the same setting in our paper and use our reported value.
import numpy as np
from sklearn.metrics.pairwise import cosine_similarity
import torch.nn as nn
#######AOI generation#######
#######You need to preprocess the original label to obtain the AOI map#########
#######Suppose M is the AOI map (h x w x n), F is the feature map (h_f x w_f x c), n is the number of classes, c is the number of channels############
smoothed_map = cv2.blur(M, (11, 11)) # kernel_size is a tunable hyperparameter
smoothed_map = cv2.resize(smoothed_map, (h_f, w_f))
mu_s = np.zeros((3, n, c))
mu_t = np.zeros((3, n, c))
cons = 1.0/(h_f*w_f) # we do not count the number of non-zero elements in AOI map as it requires additional computation and brings no more gains, one trick is that we more frequently sample areas that have road markings
small_num = 1e-10
#######moment pooling######
for i in range(h_f):
for j in range(w_f):
for cls_num in range(n):
for channel in range(c):
mu_s[0, cls_num, channel] = cons*np.sum(M[:, :, cls_num]*F[:, :, channel])
mat_1 = M[:, :, cls_num]*F[:, :, channel]-mu_s[0, cls_num, channel]
mu_s[1, cls_num, channel] = cons*np.sum(mat_1**2)
mat_2 = (M[:, :, cls_num]*F[:, :, channel]-mu_s[0, cls_num, channel])/(mu_s[1, cls_num, channel]+small_num)
mu_s[2, cls_num, channel] = cons*np.sum(mat_2**3)
########mu_t is calculated in a similar way#######
#######Inter-region affinity graph generation########
c_s_0 = cosine_similarity(mu_s[0, :, :], mu_s[0, :, :]) #c_t_0, c_s_1, ... are calculated similarly
loss = nn.MSELoss()
loss_intra_kd_0 = loss(c_s_0, c_t_0.detach())
I can't get .pth file from archive:"tar: This does not look like a tar archive". Can you check your files on google drive?
When i run sh test_pspnet_multi_scale.sh # sh test_erfnet_multi_scale.sh,something wrong happend: My torch version is 0.3.1 .
Traceback (most recent call last):
File "test_pspnet_multi_scale.py", line 13, in
from models import sync_bn
File "/home/share/make/Codes-for-IntRA-KD/models/sync_bn/init.py", line 1, in
from .functions.sync_bn import *
File "/home/share/make/Codes-for-IntRA-KD/models/sync_bn/functions/init.py", line 1, in
from .sync_bn import *
File "/home/share/make/Codes-for-IntRA-KD/models/sync_bn/functions/sync_bn.py", line 6, in
from .._ext import sync_bn_lib
File "/home/share/make/Codes-for-IntRA-KD/models/sync_bn/_ext/sync_bn_lib/init.py", line 3, in
from ._sync_bn_lib import lib as _lib, ffi as _ffi
ImportError: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
How to solve this problem ?
Hello, thanks for your sharing codes! the model you provided can only test on ApolloScape, could you provide the model which can test on CULane dataset and LLAMAS to reproduce the results of the paper?
Thanks for your sharing codes
I am trying to predict a low resolution image with pretrained ERFNet. Sadly, It doesn't work.
I think my preprocessing of image data is different from yours.
I would like to know mean/std normalization is correct.
Code I used is below.
import torch
import cv2
import utils.transforms as tf
import numpy as np
import models
import numpy as np
import matplotlib.pyplot as plt
PATH = '#/erfnet.pth'
test_image = "./test_images/test1.png"
#model load
model = models.ERFNet(37, partial_bn=False)
ckpt = torch.load(PATH)
torch.nn.Module.load_state_dict(model, ckpt['state_dict'], strict=False)
model = model.cuda()
model.eval()
#load image
img = plt.imread(test_image)[:,:,:3]
orgh,orgw = img.shape[0], img.shape[1]
zeros = np.zeros((448, 720,3))
xoffset = 2
yoffset = 10
zeros[xoffset:orgh+xoffset,yoffset:orgw+yoffset,:] = img
img = zeros
img = cv2.resize(img, None, fx=2, fy=2, interpolation=cv2.INTER_CUBIC)
plt.imshow(img)
print("image shape : ", img.shape)
#h,w = img.shape[0], img.shape[1]
#image preprocess
img *= 255.
img -= np.array([103.939, 116.779, 123.68])
img /= np.array([1.,1.,1.])
img /= 255.
h,w = img.shape[0], img.shape[1]
image = torch.from_numpy(img).permute(2, 0, 1).contiguous().float().view(1,3,h,w)
image = image.cuda()
#infer
out = model(image)
index = torch.max(out, 1)[1].squeeze().cpu().numpy()
plt.imshow(index, alpha= 0.5)
plt.show()
thanks for your sharing codes ! looking forward to the training codes of IntRA-KD,wish you can finish successfully and quickly!
@cardwing
Hi, I noted that you used the equation B x 5 + G x 3 + R
to encode the color
to some ids
, then map the ids
to the train_id
like here and here. It's a very smart way to convert the color
label to train_id
.
I wonder how you figure this out or how the coefficient is obtained? The combination of 5,3 and 1 is just a guess?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.