Code Monkey home page Code Monkey logo

codes-for-intra-kd's People

Contributors

cardwing 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

codes-for-intra-kd's Issues

about the test problems.

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.

Train Error

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

Train and build in Windows

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

moment pooling

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.

apollo datasets

thanks for your sharing codes ! in your paper, apollo dataset Validation is 10000 images, but your code vallist only have 1000 images? how about this problem?
image

update pytorch version

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,

ERFNet-SAD

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.

Test results on other data are not so satisfying

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?

Example codes of IntRA-KD

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())

test problem ?

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 ?

Test on CULane dataset

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?

image data distribution

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()

Training codes of IntRA-KD

thanks for your sharing codes ! looking forward to the training codes of IntRA-KD,wish you can finish successfully and quickly!

The way of transforming apollo color to train_id

@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?

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.