Coder Social home page Coder Social logo

xavysp / dexined Goto Github PK

View Code? Open in Web Editor NEW
692.0 17.0 157.0 158.94 MB

DexiNed: Dense EXtreme Inception Network for Edge Detection

License: MIT License

Python 100.00%
cnn-architecture edge-detection-algorithm wacv2020 edge-detection-dataset pytorch tensorflow2

dexined's Introduction

PWC PWC

DexiNed: Dense Extreme Inception Network for Edge Detection (Extended version)

- We have just updated the last version of DexiNed in Pytorch.
- The implementation with TF1 is fransfered to the "legacy" dir.
- These days we are going to updated minor changes but the model, 
  loss function, and the testing and training procedures does not need changes,
  hopefully :), if you have time please check errors and let me know
  in Issues.

This is the extended work from DexiNed presented in WACV2020. We have improved the architecture and the dataset. Unlike of the state-of-the-art CNN based edge detectors, this models has a single training stage, but it is still able to overcome those models in edge detection datasets. Moreover, Dexined does not need pre-trained weights, and it is trained from the scratch with fewer parameters tunning. To know more about DexiNed, read our first version of Dexined in ieeexplore, and its extended version in arXiv. The last version of DexiNed is implemented in Pytorch, in TF2 it will be available soon. If to want our preliminary version, please check legacy DIR.

We have prepared a basic intro to DexiNed in a video, check it in YouTube

Table of Contents

DexiNed-v1

This version was presented in WACV2020, this is the base DexiNed model implemented in TensorFlow 1

TensorFlow2

Dexined version on TF 2 is not ready

Requirements

Once the packages are installed, clone this repo as follow:

git clone https://github.com/xavysp/DexiNed.git
cd DexiNed

Project Architecture

├── data                        # Sample images for testing (paste your image here)
|   ├── lena_std.tif            # Sample 1
├── DexiNed-TF2                 # DexiNed in TensorFlow2 (in construction)   
├── figs                        # Images used in README.md
|   └── DexiNed_banner.png      # DexiNed banner
├── legacy                      # DexiNed in TensorFlow1 (presented in WACV2020)
├── utls                        # A series of tools used in this repo
|   └── image.py                # Miscellaneous tool functions
├── datasets.py                 # Tools for dataset managing 
├── dexi_utils.py               # New functions still not used in the currecnt version
├── losses.py                   # Loss function used to train DexiNed (BDCNloss2)
├── main.py                     # The main python file with main functions and parameter settings
                                # here you can test and train
├── model.py                    # DexiNed class in pythorch

Before to start please check dataset.py, from the first line of code you can see the datasets used for training/testing. The main.py, line 194, call the data for the training or testing, see the example of the code below:

    parser = argparse.ArgumentParser(description='DexiNed trainer.')
    parser.add_argument('--choose_test_data',
                        type=int,
                        default=1,
                        help='Already set the dataset for testing choice: 0 - 8')
    # ----------- test -------0--

    TEST_DATA = DATASET_NAMES[parser.parse_args().choose_test_data] # max 8
    test_inf = dataset_info(TEST_DATA, is_linux=IS_LINUX)
    test_dir = test_inf['data_dir']
    is_testing = True# current test -352-SM-NewGT-2AugmenPublish

    # Training settings
    TRAIN_DATA = DATASET_NAMES[0] # BIPED=0
    train_inf = dataset_info(TRAIN_DATA, is_linux=IS_LINUX)
    train_dir = train_inf['data_dir']

Test

As previously mentioned, the datasets.py has, among other things, the whole datasets configurations used in DexiNed for testing and training:

DATASET_NAMES = [
    'BIPED',
    'BSDS',
    'BSDS300',
    'CID',
    'DCD',
    'MULTICUE', #5
    'PASCAL',
    'NYUD',
    'CLASSIC'
] 

For example, if want to test your own dataset or image choose "CLASSIC" and save your test data in "data" dir. Before test the DexiNed model, it is necesarry to download the checkpoint here Checkpoint Pytorch and save this file into the DexiNed folder like: checkpoints/BIPED/10/(here the checkpoints from Drive), then run as follow:

python main.py --choose_test_data=-1 Make sure that in main.py the test setting be as: parser.add_argument('--is_testing', default=True, help='Script in testing mode.') DexiNed downsample the input image till 16 scales, please make sure that, in dataset_info fucn (datasets.py), the image width and height be multiple of 16, like 512, 960, and etc. **In the Checkpoint from Drive you will find the last trained checkpoint, which has been trained in the last version of BIPED dataset that will be updated soon in Kaggle **

Train

python main.py 

Make sure that in main.py the train setting be as: parser.add_argument('--is_testing', default=False, help='Script in testing mode.')

Datasets

Dataset used for Training

- The BIPED dataset has been updated to the last version and it can be download from Kaggle

BIPED (Barcelona Images for Perceptual Edge Detection): This dataset is collected and annotated in the edge level for this work. See more details, augmentation script, and download in: Option1, Option2 kaggle. The BIPED dataset has been updated, adding more annotations and correcting few mistakes, so those links have the renewed version of BIPED, if you want the older version you may ask us by email. The last performance (table below) will be updated soon.

Datasets used for Testing

Edge detection datasets

Non-edge detection datasets

Performance

The results below are from the last version of BIPEP (BIPEDv2, we leave as BIPED because this is the default version). After WACV20, the BIPED images have been checked again and added more annotations. All of those models have been trained again.

Methods ODS ODS AP
RCF .849 .861 .906
BDCN .890 .899 .934
CATS .887 .892 .817
DexiNed-f(Ours) .895 .900 .927
DexiNed-a(Ours) .893 .897 .940

Citation

If you like DexiNed, why not starring the project on GitHub!

GitHub stars

Please cite our paper if you find helpful in your academic/scientific publication,

@INPROCEEDINGS {xsoria2020dexined,
author = {X. Soria and E. Riba and A. Sappa},
booktitle = {2020 IEEE Winter Conference on Applications of Computer Vision (WACV)},
title = {Dense Extreme Inception Network: Towards a Robust CNN Model for Edge Detection},
year = {2020},
volume = {},
issn = {},
pages = {1912-1921},
keywords = {image edge detection;convolution;training;feeds;machine learning;task analysis;kernel},
doi = {10.1109/WACV45572.2020.9093290},
url = {https://doi.ieeecomputersociety.org/10.1109/WACV45572.2020.9093290},
publisher = {IEEE Computer Society},
address = {Los Alamitos, CA, USA},
month = {mar}
}

Extended version.

@article{soria2023dexined_ext,
title = {Dense extreme inception network for edge detection},
journal = {Pattern Recognition},
volume = {139},
pages = {109461},
year = {2023},
issn = {0031-3203},
doi = {https://doi.org/10.1016/j.patcog.2023.109461},
url = {https://www.sciencedirect.com/science/article/pii/S0031320323001619},
author = {Xavier Soria and Angel Sappa and Patricio Humanante and Arash Akbarinia},
keywords = {Edge detection, Deep learning, CNN, Contour detection, Boundary detection, Segmentation}
}

dexined's People

Contributors

dependabot[bot] avatar edgarriba avatar stephenwithav avatar xavysp 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  avatar  avatar

dexined's Issues

running error of python3 run_model.py --image_width=512 --image_height=512

when I follow the readme, the "python3 run_model.py --image_width=512 --image_height=512"
is not working, trace :

FailedPreconditionError (see above for traceback): Attempting to use uninitialized value Xpt/rconv2/kernel
[[node Xpt/rconv2/kernel/read (defined at /home/rediuser/DexiNed/models/dexined.py:97) ]]

OOM error (Resource Exhausted when trying to run on TensorFlow GPU)

ResourceExhaustedError (see above for traceback): OOM when allocating tensor with shape[1,16,280,480] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc

I am getting this error when I try to run the DexiNED model on Tensorflow GPU 1.13.1 with a Batch Size of 8, 4 and 1 also.

System Configuration:

  • OS: Ubuntu 18.04
  • Python: 3.7.3
  • Tensorflow GPU: 1.13.1
  • CUDA: 10.0
  • GPU: NVIDIA Geforce GTX 1080 (8 GB RAM)
  • RAM: 64 GB RAM

@xavysp Help me out on this, sir.

About ODS,OIS,AP

how to achieve the evaluation criterion in your paper, matlab?

Error in test

Hi,

When I try the command: python run_model.py --image_width=512 --image_height=512

I get the following error:

Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
	 [[node Xpt/conv1_1/Conv2D (defined at /home/DexiNed/models/dexined.py:53) ]]
	 [[node output_6 (defined at /home/DexiNed/models/dexined.py:445) ]]

I am using TF 1.13.1. How can I solve this error?

Can we upgrade the Tensor Flow version to 2.X for this project?

As I executed the code, I was getting many deprecation warnings regarding the Tensor Flow 1.1X version. So, if possible, please let us know if this repository will be upgraded to Tensor Flow 2.X or can it be done with few modifications or it cannot be upgraded?

Different visualization results.

I used your Pytorch version of the pre-training model to test the same picture. Why did I get inconsistent visual results with the article? Is it because the pytorch training model is different from the TensorFlow training model?I hope to get your advice,thanks!

how to deploy to mobile for realtime scanning

I have used the Hed to do real-time scanning on the mobile. my input image size is 256*256 but yours is 512 * 512 so i worry the inference speed with your network. I really want to try your network for that it`s contour is so thinner than hed.

non-broadcastable output operand with shape () doesn't match the broadcast shape (3,)

I try to train my own dataset , I got an error :
/home/lab606/anaconda3/envs/dexined/bin/python /home/lab606/code/DexiNed/DexiNed-Pytorch/main.py
Number of GPU's available: 1
Pytorch version: 1.0.1.post2
mean_bgr: [104.00699, 116.66877, 122.67892]
Mon Aug 31 16:27:39 2020 Epoch: 0 Sample 0/5693 Loss: 2641.2958984375
Mon Aug 31 16:27:43 2020 Epoch: 0 Sample 5/5693 Loss: 2556.032958984375
Mon Aug 31 16:27:47 2020 Epoch: 0 Sample 10/5693 Loss: 2207.842529296875
Traceback (most recent call last):
File "/home/lab606/code/DexiNed/DexiNed-Pytorch/main.py", line 358, in
main(args)
File "/home/lab606/code/DexiNed/DexiNed-Pytorch/main.py", line 343, in main
args=args)
File "/home/lab606/code/DexiNed/DexiNed-Pytorch/main.py", line 41, in train_one_epoch
for batch_id, sample_batched in enumerate(dataloader):
File "/home/lab606/anaconda3/envs/dexined/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 623, in next
return self._process_next_batch(batch)
File "/home/lab606/anaconda3/envs/dexined/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 658, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
ValueError: Traceback (most recent call last):
File "/home/lab606/anaconda3/envs/dexined/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 138, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/lab606/anaconda3/envs/dexined/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 138, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/lab606/code/DexiNed/DexiNed-Pytorch/datasets.py", line 295, in getitem
image, label = self.transform(img=image, gt=label)
File "/home/lab606/code/DexiNed/DexiNed-Pytorch/datasets.py", line 310, in transform
img -= self.mean_bgr
ValueError: non-broadcastable output operand with shape () doesn't match the broadcast shape (3,)

Process finished with exit code 1
I have checked my data and find nothing. Is it my dataset not correct? How can I solve the problem? thank you

ValueError: Cannot feed value of shape (1, 768, 768, 3) for Tensor 'Placeholder:0', which has shape '(?, 224, 224, 3)'

[28 May 2020 15h54m46s][INFO]Done restoring DexiNed model from checkpoints/DXN_CDIBD/train/DXN-79999 [28 May 2020 15h54m46s][INFO] Enterely testing set-up from /home/cdi/dinesh/dexined-aug/dataset/CDIBD/boundary/test_list.lst, size: 100 [28 May 2020 15h54m46s][INFO]testing set-up from /home/cdi/dinesh/dexined-aug/dataset/CDIBD/boundary/test_list.lst, size: 100 [28 May 2020 15h54m46s][INFO]Writing PNGs at None Traceback (most recent call last): File "run_model.py", line 138, in <module> main(args=args) File "run_model.py", line 129, in main tester.run(sess) File "/home/cdi/dinesh/dexined-aug/test.py", line 55, in run edgemap = session.run(self.model.predictions, feed_dict={self.model.images: [im]}) File "/home/cdi/anaconda3/envs/Dexi_Py37_Tfg113/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 929, in run run_metadata_ptr) File "/home/cdi/anaconda3/envs/Dexi_Py37_Tfg113/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1128, in _run str(subfeed_t.get_shape()))) ValueError: Cannot feed value of shape (1, 768, 768, 3) for Tensor 'Placeholder:0', which has shape '(?, 224, 224, 3)'

I am getting this error when I am trying to test my trained model with test image dataset of 100 images.

Mistake in convolution padding size of Denselayer

Hi Xavier, thanks for your great job!

I found a little mistake in your model's PyTorch implement.

I think the second convolution padding size should be 2 in order to keep the input's last two dimension unchanged after the DenseLayer operation. I think is should be

        self.add_module('relu1', nn.ReLU(inplace=True)),
        self.add_module('conv2', nn.Conv2d(out_features, out_features,
                                           kernel_size=3, stride=1, padding=2, bias=True)),
        self.add_module('norm2', nn.BatchNorm2d(out_features))

Btw, the script test for model.py has dimension error before this advise.

The code reference is here, please correct me if I am wrong. Thanks : )

how to annotate my own images?

hi@xavysp, i have some questions in #22 waiting for your help. here is a new question, i want to use my own images as train and validation set, could u tell me how to annotate images as you do? thanks.

I trained the model, but the results are not as good as the paper's

Hi @xavysp I trained the model using NVIDIA P100 Pascal 12G, it does not work when batchsize=8, so I set the train and validation batch size=4. another para modification is val_interval=300 (default=30).
The total training time is 71.5h (including 1.5 for data augmentation)
Max-iteration:150000
I tested Lena, here is the result. it is not as good as the paper's. is it because of batch size?

lena_std
pred-a of mine
lena_std_train1
pred-a of the author's train1
lena_std_train2
pred-a of the author's train2
lena_std
pred-f of mine
lena_std_train1
pred-f of the author's train1
lena_std_train2
pred-f of the author's train2

here are my parameter details:
parser = argparse.ArgumentParser(description='Basic details to run HED')
# dataset config
parser.add_argument('--train_dataset', default='BIPED', choices=['BIPED','BSDS'])
parser.add_argument('--test_dataset', default='CLASSIC', choices=['BIPED', 'BSDS','MULTICUE','NYUD','PASCAL','CID','DCD'])
parser.add_argument('--dataset_dir',default='./MBIPED/dataset/',type=str) # default:'/opt/dataset/'
parser.add_argument('--dataset_augmented', default=True,type=bool)
parser.add_argument('--train_list',default='train_rgb.lst', type=str) # BSDS train_pair.lst, SSMIHD train_rgb_pair.lst/train_rgbn_pair.lst
parser.add_argument('--test_list', default='test_rgb.lst',type=str) # for NYUD&BSDS:test_pair.lst, ssmihd: msi_test.lst/vis_test.lst
parser.add_argument('--trained_model_dir', default='train_1',type=str) # 'trainV2_RN'
# SSMIHD_RGBN msi_valid_list.txt and msi_test_list.txt is for unified test
parser.add_argument('--use_nir', default=False, type=bool)
parser.add_argument('--use_dataset', default=False, type=bool) # test: dataset TRUE single image FALSE
# model config
parser.add_argument('--model_state', default='train', choices=['train','test','None']) # always in None
parser.add_argument('--model_name', default='DXN',choices=['DXN','XCP','None'])
parser.add_argument('--use_v1', default=False,type=bool)
parser.add_argument('--model_purpose', default='edges',choices=['edges','restoration','None'])
parser.add_argument('--batch_size_train',default=1,type=int) # default:8
parser.add_argument('--batch_size_val',default=1, type=int) # default:8
parser.add_argument('--batch_size_test',default=1,type=int)
parser.add_argument('--checkpoint_dir', default='checkpoints',type=str)
parser.add_argument('--logs_dir', default='logs',type=str)
parser.add_argument('--learning_rate',default=1e-4, type=float) # 1e-4=0.0001
parser.add_argument('--lr_scheduler',default=None,choices=[None,'asce','desc']) # check here
parser.add_argument('--learning_rate_decay', default=0.1,type=float)
parser.add_argument('--weight_decay', default=0.0002, type=float)
parser.add_argument('--model_weights_path', default='vgg16_.npy')
parser.add_argument('--train_split', default=0.9, type=float) # default 0.8
parser.add_argument('--max_iterations', default=150000, type=int) # 100000
parser.add_argument('--learning_decay_interval',default=25000, type=int) # 25000
parser.add_argument('--loss_weights', default=1.0, type=float)
parser.add_argument('--save_interval', default=50000, type=int) # 50000
parser.add_argument('--val_interval', default=10, type=int) # default: 30
parser.add_argument('--use_subpixel', default=None, type=bool) # None=upsampling with transp conv
parser.add_argument('--deep_supervision', default=True, type= bool)
parser.add_argument('--target_regression',default=True, type=bool) # true
parser.add_argument('--mean_pixel_values', default=[103.939,116.779,123.68, 137.86], type=float)# [103.939,116.779,123.68]
# for Nir pixels mean [103.939,116.779,123.68, 137.86]
parser.add_argument('--channel_swap', default=[2,1,0], type=int)
parser.add_argument('--gpu-limit',default=1.0, type= float, )
parser.add_argument('--use_trained_model', default=True,type=bool) # for vvg16
parser.add_argument('--use_previous_trained', default=False, type=bool)
# image configuration
parser.add_argument('--image_width', default=1280, type=int) # 480 NYUD=560 BIPED=1280 default 400 other 448
parser.add_argument('--image_height', default=720, type=int) # 480 for NYUD 425 BIPED=720 default 400
parser.add_argument('--n_channels', default=3, type=int) # last ssmihd_xcp trained in 512
# test config
parser.add_argument('--test_snapshot', default=149736, type=int) # BIPED: 149736 BSDS:101179
#DexiNedv1=149736,DexiNedv2=149999
parser.add_argument('--testing_threshold', default=0.0, type=float)
parser.add_argument('--base_dir_results',default=None,type=str) # default: './results'

why didn't you use the depth-wise separable convolution?

Hi, Thank you for your great work!
I have two questions about your paper!

  1. As I wrote the title, I would like to know why you didn't use depth-wise separable convolution in you backbone.
    Since you said that you got idea from the Xception, I think you probably considered it.

  2. What would you expect if the model is trained with depth-wise separable conv?

Thanks.

Curious: Why do _DenseLayer and _DenseBlock extend nn.Sequential instead of nn.Module?

Is there a benefit to extending nn.Sequential instead of, e.g.:

class _DenseBlock(nn.Module):
    def __init__(self, num_layers, input_features, out_features):
        super(_DenseBlock, self).__init__()
        for i in range(num_layers):
            layer = nn.Sequential(['conv/bn/relu/conv/bn'])  # Swapped for _DenseLayer
            self.add_module('denselayer%d' % (i + 1), layer)
            input_features = out_features

Test cannot be executed

Hi.

When I try the command: python run_model.py --image_width=512 --image_height=512
result file will not be created because the process is completed without any error message.

When I checked it with the VScode debugger, the process ended at the place where saver.restore(session, meta_model_file) in test.py was executed

How can I solve this error?

My environment is as follows
OS Windows10 1903
Python 3.7.5
tensorflow 1.15.0 gpu_py37hc3743a6_0
tensorflow-base 1.15.0 gpu_py37h1afeea4_0
tensorflow-estimator 1.15.1 pyh2649769_0
tensorflow-gpu 1.15.0 h0d30ee6_0

Folder structure is as follows

DexiNed
│  run_model.py
│  test.py
│  train.py
│
├─checkpoints
│  └─DXN_BIPED
│      └─train
│          ├─data_lists
│          │  └─MDBD
│          │          test_pair.lst
│          │
│          └─train_1
│                  checkpoint
│                  DXN-149736.data-00000-of-00001
│                  DXN-149736.index
│                  DXN-149736.meta
│
├─data
│      lena_std.tif
│
├─models
│  │  dexined.py
│  │
│  └─__pycache__
│          dexined.cpython-37.pyc
│
├─utls
│  │  dataset_manager.py
│  │  losses.py
│  │  utls.py
│  │
│  └─__pycache__
│          dataset_manager.cpython-37.pyc
│          losses.cpython-37.pyc
│          utls.cpython-37.pyc
...
omit fig, DexiNed-Pytorch,__pycache__ folders and some files

Console message is as follow

(develop) PS D:\DownLoad\DexiNed>  ${env:DEBUGPY_LAUNCHER_PORT}='56968'; & 'D:\Program\anaconda\envs\develop\python.exe' 'c:\Users\EF070104\.vscode\extensions\ms-python.python-2020.3.71659\pythonFiles\lib\python\debugpy\wheels\debugpy\launcher' 'd:\DownLoad\DexiNed\run_model.py' '--image_width=512' '--image_height=512' 
2020-05-07 13:08:29.825687: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
WARNING:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  * https://github.com/tensorflow/addons
  * https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.

WARNING:tensorflow:From d:\DownLoad\DexiNed\run_model.py:80: The name tf.GPUOptions is deprecated. Please use tf.compat.v1.GPUOptions instead.

WARNING:tensorflow:From d:\DownLoad\DexiNed\run_model.py:85: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

WARNING:tensorflow:From d:\DownLoad\DexiNed\run_model.py:85: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.

2020-05-07 13:08:36.481410: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX
2020-05-07 13:08:36.545803: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2020-05-07 13:08:36.608447: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with properties: 
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.582
pciBusID: 0000:05:00.0
2020-05-07 13:08:36.633484: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
2020-05-07 13:08:36.663004: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_100.dll
2020-05-07 13:08:36.679586: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_100.dll
2020-05-07 13:08:36.691120: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_100.dll
2020-05-07 13:08:36.707423: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_100.dll
2020-05-07 13:08:36.733712: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_100.dll
2020-05-07 13:08:36.784385: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-05-07 13:08:36.811904: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu devices: 0
2020-05-07 13:08:37.929742: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-05-07 13:08:37.947008: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1165]      0 
2020-05-07 13:08:37.958089: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 0:   N
2020-05-07 13:08:37.999426: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 8784 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:05:00.0, compute capability: 6.1)
WARNING:tensorflow:From d:\DownLoad\DexiNed\models\dexined.py:30: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

WARNING:tensorflow:From d:\DownLoad\DexiNed\models\dexined.py:48: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

WARNING:tensorflow:From d:\DownLoad\DexiNed\models\dexined.py:53: conv2d (from tensorflow.python.layers.convolutional) is deprecated and will be removed in a future version.      
Instructions for updating:
Use `tf.keras.layers.Conv2D` instead.
WARNING:tensorflow:From D:\Program\anaconda\envs\develop\lib\site-packages\tensorflow_core\python\layers\convolutional.py:424: Layer.apply (from tensorflow.python.keras.engine.base_layer) is deprecated and will be removed in a future version.
Instructions for updating:
Please use `layer.__call__` method instead.
WARNING:tensorflow:From d:\DownLoad\DexiNed\models\dexined.py:297: conv2d_transpose (from tensorflow.python.layers.convolutional) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.keras.layers.Conv2DTranspose` instead.
[07 May 2020 13h08m41s][INFO]Build model finished: 3.7531s
WARNING:tensorflow:From d:\DownLoad\DexiNed\test.py:37: The name tf.train.Saver is deprecated. Please use tf.compat.v1.train.Saver instead.

Unable to test on different model than trained model

I trained the model on the BSDS500 dataset and wanted to test it in the BIPED dataset but when use_previous_trained is True the implementation only wants to use a DXN_BIPED checkpoint folder.
And if I rename my checkpoint folder to match I get a "not a valid checkpoint error"

[18 May 2020 16h16m33s][INFO]Build model finished: 1.6700s
WARNING:tensorflow:From /home/jupyter/repos/DexiNed/test.py:37: The name tf.train.Saver is deprecated. Please use tf.compat.v1.train.Saver instead.

[18 May 2020 16h16m34s][ERROR] Error setting up DexiNed traied model, The passed save_path is not a valid checkpoint: checkpoints/DXN_BIPED/train_1/DXN-149736
[18 May 2020 16h16m34s][INFO]Writing PNGs at None
Traceback (most recent call last):
File "run_model.py", line 131, in
main(args=args)
File "run_model.py", line 121, in main
tester.run(sess)
File "/home/jupyter/repos/DexiNed/test.py", line 69, in run
im, file_name = get_single_image(self.args,file_path=test_data[i])
File "/home/jupyter/repos/DexiNed/utls/dataset_manager.py", line 1272, in get_single_image
h,w,c=img.shape
AttributeError: 'NoneType' object has no attribute 'shape'

I trained bsds dataset with dexined, but errors occoured when I used the pretrained model to test

i trained the bsds dataset successfully, but i failed to test with it. here are errors, i don't know why, how to fix it? @xavysp

2020-06-16 16:18:50.002348: W tensorflow/core/framework/op_kernel.cc:1502] OP_REQUIRES failed at save_restore_v2_ops.cc:184 : Not found: Key Xpt/output1_biases_1 not
found in checkpoint
?[31m[16 Jun 2020 16h18m50s][ERROR] Error setting up DexiNed traied model, Restoring from checkpoint failed. This is most likely due to a Variable name or other grap
h key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Key Xpt/output1_biases_1 not found in checkpoint
[[node save/RestoreV2 (defined at D:\PycharmProjects2\edge-detection-DexiNed\test.py:37) ]]

Original stack trace for 'save/RestoreV2':
File "run_model.py", line 131, in
main(args=args)
File "run_model.py", line 120, in main
tester.setup(sess)
File "D:\PycharmProjects2\edge-detection-DexiNed\test.py", line 37, in setup
saver = tf.train.Saver()
File "D:\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py", line 825, in init
self.build()
File "D:\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py", line 837, in build
self._build(self._filename, build_save=True, build_restore=True)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py", line 875, in _build
build_restore=build_restore)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py", line 508, in _build_internal
restore_sequentially, reshape)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py", line 328, in _AddRestoreOps
restore_sequentially)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py", line 575, in bulk_restore
return io_ops.restore_v2(filename_tensor, names, slices, dtypes)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_io_ops.py", line 1696, in restore_v2
name=name)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3616, in create_op
op_def=op_def)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2005, in init
self._traceback = tf_stack.extract_stack()
?[0m
?[32m[16 Jun 2020 16h18m50s][INFO]Writing PNGs at None?[0m
Traceback (most recent call last):
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1356, in _do_call
return fn(*args)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1341, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1429, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.FailedPreconditionError: 2 root error(s) found.
(0) Failed precondition: Attempting to use uninitialized value Xpt/output6_biases_4
[[{{node Xpt/output6_biases_4/read}}]]
[[output_4/_523]]
(1) Failed precondition: Attempting to use uninitialized value Xpt/output6_biases_4
[[{{node Xpt/output6_biases_4/read}}]]
0 successful operations.
0 derived errors ignored.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "run_model.py", line 131, in
main(args=args)
File "run_model.py", line 121, in main
tester.run(sess)
File "D:\PycharmProjects2\edge-detection-DexiNed\test.py", line 71, in run
edgemap = session.run(self.model.predictions, feed_dict={self.model.images: [im]})
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 950, in run
run_metadata_ptr)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1173, in _run
feed_dict_tensor, options, run_metadata)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1350, in _do_run
run_metadata)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1370, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.FailedPreconditionError: 2 root error(s) found.
(0) Failed precondition: Attempting to use uninitialized value Xpt/output6_biases_4
[[node Xpt/output6_biases_4/read (defined at D:\PycharmProjects2\edge-detection-DexiNed\models\dexined.py:290) ]]
[[output_4/_523]]
(1) Failed precondition: Attempting to use uninitialized value Xpt/output6_biases_4
[[node Xpt/output6_biases_4/read (defined at D:\PycharmProjects2\edge-detection-DexiNed\models\dexined.py:290) ]]
0 successful operations.
0 derived errors ignored.

Original stack trace for 'Xpt/output6_biases_4/read':
File "run_model.py", line 131, in
main(args=args)
File "run_model.py", line 120, in main
tester.setup(sess)
File "D:\PycharmProjects2\edge-detection-DexiNed\test.py", line 20, in setup
self.model = dexined(self.args)
File "D:\PycharmProjects2\edge-detection-DexiNed\models\dexined.py", line 37, in init
self.define_model()
File "D:\PycharmProjects2\edge-detection-DexiNed\models\dexined.py", line 240, in define_model
kernel_init=weight_init)
File "D:\PycharmProjects2\edge-detection-DexiNed\models\dexined.py", line 397, in side_layer
name=name, upscale=upscale, sub_pixel=sub_pixel)
File "D:\PycharmProjects2\edge-detection-DexiNed\models\dexined.py", line 290, in upsample_block
name=name + 'biases{}'.format(i))
File "D:\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 259, in call
return cls._variable_v1_call(*args, **kwargs)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 220, in _variable_v1_call
shape=shape)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 198, in
previous_getter = lambda **kwargs: default_variable_creator(None, **kwargs)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 2511, in default_variable_creator
shape=shape)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 263, in call
return super(VariableMetaclass, cls).call(*args, **kwargs)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 1568, in init
shape=shape)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 1755, in _init_from_args
self._snapshot = array_ops.identity(self._variable, name="read")
File "D:\Anaconda3\lib\site-packages\tensorflow\python\util\dispatch.py", line 180, in wrapper
return target(*args, **kwargs)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py", line 86, in identity
ret = gen_array_ops.identity(input, name=name)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 4253, in identity
"Identity", input=input, name=name)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3616, in create_op
op_def=op_def)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2005, in init
self._traceback = tf_stack.extract_stack()

test result?

when I test the single image, I got the following result, but it is not the expected one.
Is there something wrong with my operation? Thank you! I'm a beginner.
image

predict time

I test my own dataset ,and predict one 1280*720 image consume about 870ms? Is it right?

TFlite conversion.

I tried to convert it for a TFLite version. But the FusedBatchNorm layers are not being converted. Is there a solution for this?

Many questions about training

Thank u for sharing your wonderful work. I tested my images, it looks good. I am interested in this work. Here are some questions about training:
Question 1. According to your instruction, I downloaded the BIPED data, and executed data augmentation, and now the dataset is very large, nearly 10G. my question is: the images in the augmented dataset have different sizes, so how to set image size in run_model.py? still 1280X720?

Question 2. in test_rgb.lst and train_rgb.lst, the both columns in each row are the same, such as in test_rgb.lst:
rgbr/RGB_008.jpg rgbr/RGB_008.png
rgbr/RGB_010.jpg rgbr/RGB_010.png
rgbr/RGB_017.jpg rgbr/RGB_017.png
rgbr/RGB_025.jpg rgbr/RGB_025.png
and in train_rgb.lst, such as:
rgbr/aug/p1/RGB_001.jpg rgbr/aug/p1/RGB_001.png
rgbr/aug/p1/RGB_002.jpg rgbr/aug/p1/RGB_002.png
rgbr/aug/p1/RGB_003.jpg rgbr/aug/p1/RGB_003.png
my question is why there is no edge image in each line?

Question 3. after augmentation, the total training images are 57600, you set max_iterations=150000, which means each image will be trained nearly 3 times, is that right?

Question 4. My dataset locates at: ./MBIPED/dataset/ BIPED, like:
./MBIPED/dataset/ BIPED/edges/edge_maps/test
./MBIPED/dataset/ BIPED/edges/edge_maps/train
./MBIPED/dataset/ BIPED/edges/imgs/test
./MBIPED/dataset/ BIPED/edges/imgs/train
./MBIPED/dataset/ BIPED/edges/test_rgb.lst
./MBIPED/dataset/ BIPED/edges/train_rgb.lst
And then I set the parameter '--dataset_dir',default='./MBIPED/dataset/', is it right?

Question 5. How to understand and use the following parameters?
'--use_nir', default=False, type=bool
'--use_v1', default=False,type=bool
'--deep_supervision', default=True, type= bool
'--testing_threshold', default=0.0, type=float

Question 6. '--train_split', default=0.9, type=float. This is to split the data set into train set and validation set, right?

Question 7. How long will the training take if I use 1080 ti GPU?

Training with run_model.py: TypeError: expected str, bytes or os.PathLike object, not NoneType

I downloaded the checkpoint files from the google drive link and placed them in ./DexiNed-master/DexiNed-TF2/DXN_BIPED and then ran

python run_model.py --image_width=512 --image_height=512

and got the error below

Traceback (most recent call last):
  File "run_model.py", line 131, in <module>
    main(args=args)
  File "run_model.py", line 108, in main
    trainer.run(sess)
  File "/home/me/Desktop/DexiNed-master/train.py", line 32, in run
    train_data = data_parser(self.args)
  File "/home/me/Desktop/DexiNed-master/utls/dataset_manager.py", line 1018, in data_parser
    if args.train_dataset.lower() == 'biped' else os.path.join(args.dataset_dir, args.train_dataset)
  File "/home/me/anaconda3/lib/python3.6/posixpath.py", line 80, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

PyTorch Training Stuck at Epoch 0

After following the configuration mentioned in the README, my training loop is stuck at this point -

Mon Nov 16 01:53:58 2020 Epoch: 0 Sample 75/76 Loss: 30482.720703125

And doesn't move any further, just stuck there.

Mean BGR values for PyTorch pretrained model?

What is the mean BGR values for the PyTorch pretrained model?

[104.00699, 116.66877, 122.67892, 137.86],
[103.939,116.779,123.68], or
[104.00699, 116.66877, 122.67892]

But they seemed to be quite similar.

Getting an error on loading checkpoints

I am getting the following error on running the model.
FailedPreconditionError (see above for traceback): Attempting to use uninitialized value Xpt/BatchNorm_34/beta [[node Xpt/BatchNorm_34/beta/read (defined at /usr/local/lib/python3.5/dist-packages/tensorflow/contrib/framework/python/ops/variables.py:277) = Identity[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](Xpt/BatchNorm_34/beta)]]

I am using tensorflow version 1.12.3

Should I initialize the weights after loading them ?

how to test one picture

How to configure the run_model.py,parser.add_argument('--dataset_dir',default=None,type=str)
where can i put the one picture to test? Thank you very much!

Setting up DexiNed traied model

Hi,

I'm really new to this, but found your work very interesting. I wonder is it possible to set my own data as training set? How should I do that? My images are all jpg files.

BTW, is it possible to thinner the lines in the results?

One more question, what do the four folders (pred-a, pred-f, etc.) in the results folder stand for separate?

Thanks!!

I finished training, here is the evaluation result.

@xavysp hi, I finished training, the results are good, but the evaluation results are far from the paper. here are the results: Boundary
ODS: F( 0.79, 0.66 ) = 0.72 [th = 0.70]
OIS: F( 0.81, 0.68 ) = 0.74
Area_PR = 0.65
isoF

here are some questions:

  1. the width and height of BSDS images are 481X321, they are not divisible by 16. so I resized to 480X320 and test, and then resize the test results to 481X321 again (.jpg format).
  2. I used the following matlab code for NMS:

clear; clc;
path_to_pdollar_edges = 'D:\PycharmProjects2\edge-detection-DexiNed\evaluation\pdollar-edges';
path_to_pdollar_toolbox = 'D:\PycharmProjects2\edge-detection-DexiNed\evaluation\pdollar-toolbox';
path_to_input = 'D:\PycharmProjects2\edge-detection-DexiNed\evaluation\dexined-pred-f-321X481';
path_to_output = 'D:\PycharmProjects2\edge-detection-DexiNed\evaluation\nms';
addpath(genpath(path_to_pdollar_edges));
addpath(genpath(path_to_pdollar_toolbox));
%mkdir(path_to_output);
iids = dir(fullfile(path_to_input, '.jpg'));
for i = 1:length(iids)
edge = imread(fullfile(path_to_input, iids(i).name));
edge=rgb2gray(edge);
edge = 1-single(edge)/255;
[Ox, Oy] = gradient2(convTri(edge, 4));
[Oxx, ~] = gradient2(Ox);
[Oxy, Oyy] = gradient2(Oy);
O = mod(atan(Oyy .
sign(-Oxy) ./ (Oxx + 1e-5)), pi);
% 2 for BSDS500 and Multi-cue datasets, 4 for NYUD dataset
edge = edgesNmsMex(edge, O, 2, 5, 1.01, 8);
imwrite(edge, fullfile(path_to_output, [iids(i).name(1:end-4) '.png']));
end

these codes are modified from RCF's edge_nms. m, however, there are some differences. i added edge=rgb2gray(edge); because the output of defined is not gray model.
3. use bench_bsds500.m provided by BSDS to evaluate the results.

tell me if I were wrong. thanks.

How to convert to tflite?

I tried to use DexiNed-TF2 to convert tflite, but found that the model volume has not changed after the conversion and it cannot be used in mobile phones. Is there any related documents?

State of PyTorch version pretrained model?

Hi, I see there is a checkpoint in the checkpoint folder within the DexiNed-Pytorch folder. May I know what is the status of this checkpoint? How is the performance of the PyTorch model in comparison to your TF2 model?

I'm asking this because I'm seeing quite some mistakes in the code. I have made quite some changes to the code while trying to maintain the original intention of the code. Please checkout my pull request.

About the evaluation index

Hello, I would like to ask if your matlab code can evaluate the results of the model I wrote by myself

a tinny setting mistake between run_model.py and dexined.py

in run_model.py line56: parser.add_argument('--use_subpixel', default=None, type=bool) # None=upsampling with transp conv

but in dexined.py line316: elif sub_pixel is None: # Upsampling by bilinear interpolation

@xavysp I think there is a conflict between each other. line56 of run_model.py should be changed as follow:
parser.add_argument('--use_subpixel', default=False, type=bool) # False =upsampling with transp conv

Bug in loading a previous trained checkpoint with custom checkpoint_dir

When use a different checkpoint_dir with --use_previous_trained True, run_model.py fails to load the checkpoint.

The problem is in train.py, line 50 :

model_path = os.path.join('checkpoints',self.args.model_name+

should be replace with:

model_path = os.path.join(self.args.checkpoint_dir,self.args.model_name+

some error in TF2.0

There may be some errors in run_model.py in DexiNed-TF2 folder, accurately speaking,in 38 line:

val_log_dir =os.path.join(summary_dir,'test')

It could be

val_log_dir =os.path.join(summary_dir,'valid')

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.