Giter VIP home page Giter VIP logo

zlckanata / deepglobe-road-extraction-challenge Goto Github PK

View Code? Open in Web Editor NEW
630.0 15.0 196.0 2.15 MB

D-LinkNet: LinkNet with Pretrained Encoder and Dilated Convolution for High Resolution Satellite Imagery Road Extraction

Home Page: http://openaccess.thecvf.com/content_cvpr_2018_workshops/papers/w4/Zhou_D-LinkNet_LinkNet_With_CVPR_2018_paper.pdf

License: MIT License

Python 100.00%
deepglobe-road-extraction-challenge

deepglobe-road-extraction-challenge's Introduction

DeepGlobe-Road-Extraction-Challenge

Code for the 1st place solution in DeepGlobe Road Extraction Challenge.

Requirements

  • Cuda 8.0
  • Python 2.7
  • Pytorch 0.2.0
  • cv2

Usage

Data

Place 'train', 'valid' and 'test' data folders in the 'dataset' folder.

Data is from DeepGlobe Road Extraction Challenge. You should sign in first to get the data.

Train

  • Run python train.py to train the default D-LinkNet34.

Predict

  • Run python test.py to predict on the default D-LinkNet34.

Download trained D-LinkNet34

deepglobe-road-extraction-challenge's People

Contributors

zlckanata 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deepglobe-road-extraction-challenge's Issues

Issue in unet code

Hi, there is a small correction in the unet code

In Dblock the nn.Conv2d accepts integer channel sizes so channel/2 is not acceptable, changing it to int(channel/2) works though

When I run the "test.py", to about 58, there will be occur the error "ValueError: Axes=(0, 1) out of range for array of ndim=0."

Traceback (most recent call last):
File "test.py", line 149, in
mask = solver.test_one_img_from_path(source+name)
File "test.py", line 32, in test_one_img_from_path
return self.test_one_img_from_path_2(path)
File "test.py", line 94, in test_one_img_from_path_2
img90 = np.array(np.rot90(img))
File "/home/yangzihao/.conda/envs/py27/lib/python2.7/site-packages/numpy/lib/function_base.py", line 121, in rot90
.format(axes, m.ndim))
ValueError: Axes=(0, 1) out of range for array of ndim=0.

I don't konw how to solve this, please help me orz

Error: axis 2 is out of bounds for array of dimension 1

The label image will be read as NoneType when running this line:
mask = cv2.imread(os.path.join(root+'{}_mask.png').format(id), cv2.IMREAD_GRAYSCALE)
Maybe it should be changed like this:
mask = cv2.imread(os.path.join(root, '{}_mask.png').format(id), cv2.IMREAD_GRAYSCALE)

希望借用codalab账号

我在复现您的代码后,申请了对应的比赛但是一直没有收到批复,无法对模型输出的验证集的mask进行iou精度评估。
或者是否向您借一下codalab的账号以提交结果进行精度评估?
谢谢!

init

我能看看你的init里面的程序吗

get IOU Score?

Hello, there is a small thing I would like to ask you. Since the verification set provided by the DeepGlobal game does not have a GT image, I want to get the IOU of my own training model on the verification set. How should I submit the results of my prediction? I look forward to your reply and wish you a happy life.

Licensing Terms

I wanted to inquire under what license this code is issued?. As I do not see a LICENSE file and I would like to request that one is added. MIT or Apache would work for me, but of course please use whatever license terms you want

RuntimeError: cuda runtime error (2) : out of memory at /opt/conda/conda-bld/pytorch_1512946747676/work/torch/lib/THC/generic/THCStorage.cu:58

when i run python train.py using python virtual environment it shows the error. how to solve the error,anyone solved it? thanks a lot . Another, i have tried to use small batch size,but is doesn't work.

<torch.utils.data.dataloader.DataLoader object at 0x7f3868b7d790>
THCudaCheck FAIL file=/opt/conda/conda-bld/pytorch_1512946747676/work/torch/lib/THC/generic/THCStorage.cu line=58 error=2 : out of memory
Traceback (most recent call last):
File "train.py", line 47, in
train_loss = solver.optimize()
File "/mnt/saners-extend/DeepGlobe-Road-Extraction-Challenge/framework.py", line 62, in optimize
pred = self.net.forward(self.img)
File "/home/anaconda3/envs/road_extract/lib/python2.7/site-packages/torch/nn/parallel/data_parallel.py", line 66, in forward
return self.module(*inputs[0], **kwargs[0])
File "/home/anaconda3/envs/road_extract/lib/python2.7/site-packages/torch/nn/modules/module.py", line 325, in call
result = self.forward(*input, **kwargs)
File "/mnt/saners-extend/DeepGlobe-Road-Extraction-Challenge/networks/dinknet.py", line 176, in forward
e3 = self.encoder3(e2)
File "/home/anaconda3/envs/road_extract/lib/python2.7/site-packages/torch/nn/modules/module.py", line 325, in call
result = self.forward(*input, **kwargs)
File "/home/anaconda3/envs/road_extract/lib/python2.7/site-packages/torch/nn/modules/container.py", line 67, in forward
input = module(input)
File "/home/anaconda3/envs/road_extract/lib/python2.7/site-packages/torch/nn/modules/module.py", line 325, in call
result = self.forward(*input, **kwargs)
File "/home/anaconda3/envs/road_extract/lib/python2.7/site-packages/torchvision-0.1.9-py2.7.egg/torchvision/models/resnet.py", line 41, in forward
File "/home/anaconda3/envs/road_extract/lib/python2.7/site-packages/torch/nn/modules/module.py", line 325, in call
result = self.forward(*input, **kwargs)
File "/home/anaconda3/envs/road_extract/lib/python2.7/site-packages/torch/nn/modules/conv.py", line 277, in forward
self.padding, self.dilation, self.groups)
File "/home/anaconda3/envs/road_extract/lib/python2.7/site-packages/torch/nn/functional.py", line 90, in conv2d
return f(input, weight, bias)
RuntimeError: cuda runtime error (2) : out of memory at /opt/conda/conda-bld/pytorch_1512946747676/work/torch/lib/THC/generic/THCStorage.cu:58

推理结果全白或全黑

请问您在训练过程中有没有遇到推理结构全白或者全黑的情形?这可能是什么原因导致的呢?分析了很多原因,做了很多修改和尝试,但推理结果依然是全白全黑,该怎么处理呢

Requests on D-LinkNet figure 3 results

Hello zlkanata,

I'm Yooseung Wang, ML Research Intern @ SIA Lab in South Korea.
We're inspired by your works on DeepGlobe Challenge what you've done so that we're working on DeepGlobe datasets to improve performances starting from your models, D-LinkNet. The reason why I mail you is that we want to compare our results with yours,especially in figure 3 of your D-LinkNet Workshop Paper.(CVPRW). Could you please give me the raw files of figure 3 (16 raw files, example results of three models.) in your D-LinkNet paper which had been published @ CVPRW. Of course Thanks a lot if you give me all outputs for three models (2334 images3(UNet,LinkNet34D-LinkNet34)).
Hope your great successes in your future work!
my email address is here : [email protected]

Could you provide the trained the weight that already trained?

Pretty thanks for your awesome contribution!
But would it be possible for you to provide the weights that were already trained? Since that might save us a lot of training time and help us to evaluate the code?
I once tried to solver.load('weights/weights') in test.py but it failed 0.0

运行train.py时出现bug,load训练数据是否有误

错误出现在train.py中低34行左右函数dataloader中data_loader = torch.utils.data.DataLoader(
dataset,
batch_size=batchsize,
shuffle=True,
num_workers=4,
)

ValueError: num_samples should be a positive integer value, but got num_samples=0
我的运行环境为:python3.6 pytorch1.3.1
打扰您了,期待您的回复,祝您在新的一年心想事成,平安喜乐~~

Running error on train.py

Hello, I have a question when running Python3 train.py, here is the error:

Traceback (most recent call last):
File "train.py", line 39, in
num_workers=4)
File "/home/ev1-ws4/anaconda3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 176, in init
sampler = RandomSampler(dataset)
File "/home/ev1-ws4/anaconda3/lib/python3.5/site-packages/torch/utils/data/sampler.py", line 66, in init
"value, but got num_samples={}".format(self.num_samples))
ValueError: num_samples should be a positive integer value, but got num_samples=0

I output the length of "imagelist" and "trainlist", which is 6226 and 0, respectively.

imagelist = filter(lambda x: x.find('sat')!=-1, os.listdir(ROOT)) #length: 6226
trainlist = map(lambda x: x[:-8], imagelist) #length: 0
x = list(imagelist)
y = list(trainlist)
print(len(x), len(y))

Any ideas how to solve this problem? Many thanks.

Testing higher resolution data with lower-resolution trained model

Hi
I have trained the d-link model on the training images from DeepGlobe data. Now I'm trying to run the test on the data from Roadtracer images, which are 4096x4096. I changed the resolution in the test.py file. However, it eventually gives a CUDA memory error, despite having 10 GB of GPU memory. Do you have any suggestions to make this work?

train.py : RuntimeError: invalid argument 1:

当我运行trian.py的时候出现这个问题,请问北邮大神遇到过吗?需要如何解决?
Traceback (most recent call last):
File "ttest.py", line 71, in
data_loader_iter = iter(data_loader)
File "/home/Software/anaconda3/envs/python-3.5/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 310, in iter
return DataLoaderIter(self)
File "/home/Software/anaconda3/envs/python-3.5/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 180, in init
self._put_indices()
File "/home/Software/anaconda3/envs/python-3.5/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 219, in _put_indices
indices = next(self.sample_iter, None)
File "/home/Software/anaconda3/envs/python-3.5/lib/python3.5/site-packages/torch/utils/data/sampler.py", line 119, in iter
for idx in self.sampler:
File "/home/Software/anaconda3/envs/python-3.5/lib/python3.5/site-packages/torch/utils/data/sampler.py", line 50, in iter
return iter(torch.randperm(len(self.data_source)).long())
RuntimeError: invalid argument 1: must be strictly positive at /opt/conda/conda-bld/pytorch_1512954043090/work/torch/lib/TH/generic/THTensorMath.c:2184

i got a problem :ValueError: num_samples should be a positive integer value, but got num_samples=0

Traceback (most recent call last):
File "C:\DeepGlobe-Road-Extraction-Challenge-master\train.py", line 31, in
data_loader = torch.utils.data.DataLoader(
File "C:\software\Python39\lib\site-packages\torch\utils\data\dataloader.py", line 266, in init
sampler = RandomSampler(dataset, generator=generator) # type: ignore
File "C:\software\Python39\lib\site-packages\torch\utils\data\sampler.py", line 103, in init
raise ValueError("num_samples should be a positive integer "
ValueError: num_samples should be a positive integer value, but got num_samples=0

so how could this be resolved?

希望借用codalab账号

我在复现您的代码后,申请了对应的比赛但是一直没有收到批复,无法对模型输出的验证集的mask进行iou精度评估。
是否可以向您借一下codalab的账号以提交结果进行精度评估?
我的邮箱:[email protected]
谢谢!

Error when I run train.py

① (when num_workers=4)
raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str)) from e
RuntimeError: DataLoader worker (pid(s) 12488) exited unexpectedly
② (when num_workers=0)
Process finished with exit code -1073741795 (0xC000001D)

anyone please who can help

problem when running test.py

$ python test.py
0 0.00
Traceback (most recent call last):
File "test.py", line 150, in
mask[mask>4.0] = 255
TypeError: 'NoneType' object does not support item assignment

关于数据集

请问您可以提供官方数据集的验证集标签数据吗,我在复现您的代码后,申请了对应的比赛但是一直没有收到批复,无法对模型输出的验证集的mask进行iou精度评估。
或者是否向您借一下codalab的账号以提交结果进行精度评估?
谢谢!

Scripts for computing IoU

Hi

Is the code for computing IoU and mIoU also included in the scripts, or does that have to be done separately from the resultant predictions in the submits directory?

关于代码使用的一个疑惑,IOU计算和标签

@zlkanata 您好,作为一个初学者,我在使用你的代码的时候有几个疑问,不知道你能不能抽空回答一下:
1.代码里我没找到计算iou的部分,请问您能再上传一下吗。
2.我下载了官方的数据集,验证集没有标签,所以感到很困惑,怎么来验证模型的效果以及计算iou。
谢谢了~

test.py

Why the batch_size for test is 4. I see that you concatenate the image together. Can I use the batchsize equal 1?

对于给出的模型的验证集的结果有一些疑问

我使用的是readme给模型,在运行test.py文件之后生成对于验证集的预测mask,发现好多mask都是空白的,并且其他的有黑色mask的结果并不是卫星图片当中的道路,这个是我代码改错了吗?我仅仅resize了一下图片的结果

def test_one_img_from_path_4(self, path):
    img = cv2.imread(path)#.transpose(2,0,1)[None]
    img=cv2.resize(img,(1024,1024),interpolation=cv2.INTER_LINEAR)
    img90 = np.array(np.rot90(img))
    img90=cv2.resize(img90,(1024,1024),interpolation=cv2.INTER_LINEAR)
    img1 = np.concatenate([img[None],img90[None]])

TypeError: new(): argument 'size' must be tuple of ints, but found element of type float at pos 2

Thanks for your outstanding work. I am getting weird errors during unet training would you please give me any suggestions?
File "/home/jhone/1_DeepUnet/pytorch_version/utils.py", line 36, in train
model = Dunet().to(device).float()
File "/home/jhone/1_DeepUnet/pytorch_version/model.py", line 49, in init
self.dilate_center = Dblock(512)
File "/home/jhone/1_DeepUnet/pytorch_version/model.py", line 15, in init
self.dilate1 = nn.Conv2d(channel/2, channel, kernel_size=3, dilation=1, padding=1)
File "/home/jhone/anaconda3/envs/torch/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 338, in init
False, _pair(0), groups, bias, padding_mode)
File "/home/jhone/anaconda3/envs/torch/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 48, in init
out_channels, in_channels // groups, *kernel_size))
TypeError: new(): argument 'size' must be tuple of ints, but found element of type float at pos 2
(torch) ali@ali-System

unet预测全黑

您好,UNet多次修改学习率(e-3/-4/-5/-6/-7) 训练,但是预测结果图全黑,请问 该怎么办呢? 按照网上说的方法修改后,还是全黑。只有lr=e-6,epoch=200时预测结果显示,但是效果非常不好!

Logic of a method in test.py

Hi, Thank you for your wonderful work! May I ask what's your logic for the 'test_one_img_from_path_1' method in test.py? Specifically, why did you need to do the following before calling net.forward?

img90 = np.array(np.rot90(img))
img1 = np.concatenate([img[None],img90[None]])
img2 = np.array(img1)[:,::-1]
img3 = np.concatenate([img1,img2])
img4 = np.array(img3)[:,:,::-1]
img5 = np.concatenate([img3,img4]).transpose(0,3,1,2)
img5 = np.array(img5, np.float32)/255.0 * 3.2 -1.6

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.