Giter VIP home page Giter VIP logo

gmnet's Introduction

GMNet: Graph Matching Network for Large Scale Part Semantic Segmentation in the Wild

Official Tensorflow Implementation for "GMNet: Graph Matching Network for Large Scale Part Semantic Segmentation in the Wild", U. Michieli, E. Borsato, L. Rossi, P. Zanuttigh, ECCV 2020

In this work, we propose a novel framework combining higher object-level context conditioning and part-level spatial relationships to address the semantic segmentation of parts of multiple objects.

To tackle object-level ambiguity, a class-conditioning module is introduced to retain class-level semantics when learning parts-level semantics. In this way, mid-level features carry also this information prior to the decoding stage.

To tackle part-level ambiguity and localization we propose a novel adjacency graph-based module that aims at matching the relative spatial relationships between ground truth and predicted parts.

The webpage of the paper is here

The full paper can be downloaded from here

The slides and the recordings of the presentation are available:
1 min slides
1 min talk
10 min slides
10 min talk

teaser

teaser

Requirements and Installation

This repository uses Python 3.x and Tensorflow 1.13 (TF 1.10 - 1.15 should work just well)

The code is built upon the official implementation of the Deeplab architecture. We refer to their installation guidelines.

In particular remember to export the python path back to (assuming you are in Deeplab/research/deeplab/):

export PYTHONPATH=$PYTHONPATH:pwd:pwd/../../../Deeplab

Known Issue:

Currently, there is a bug in the part-level tfrecords generation.

Temporary Workaround: while the issue is being investigate you can directly download part-level tfrecords from here and then perform training and evaluation.

Download data and checkpoints

In this project we used two datasets: Pascal-Part-58 and Pascal-Part-108.

The datasets and some checkpoints of interest are available here

Generate object-level tfrecords

To generate the tfrecords of the Pascal-VOC2012 with 21 classes:

python -u build_voc2012_data.py
--image_folder dataset/RGB
--semantic_segmentation_folder dataset/label21
--list_folder dataset
--output_dir tfrecord_21_classes

NB: all the paths need to be adjusted properly. For information on the flags, see their helper description.

Generate object-level softmax maps

Then, we generate object-level softmax maps for object-level conditioning while learning parts. You may use whatever semantic segmentation network pretrained on object-level classes. The higher the accuracy at the object level and the more effective will result the guidance.

For convenience, we trained a model on the 21 object-level classes of Pascal and we place it in the archive file downloaded earlier. Given such checkpoint, you need to run an inference pass saving the softmax maps for both train and val splits respectively:

python -u vis_classes.py
--logtostderr
--eval_split train
--model_variant resnet_v1_101_beta
--atrous_rates 6
--atrous_rates 12
--atrous_rates 18
--output_stride 16
--decoder_output_stride 4
--eval_crop_size "513,513"
--checkpoint_dir TRAIN_21_classes
--vis_logdir VIS_21_classes
--dataset pascal_voc_seg
--dataset_dir tfrecord_21_classes
--max_number_of_evaluations 1
--save_softmax 1
1> VIS_21_classes.txt 2>&1

python -u vis_classes.py
--logtostderr
--eval_split train
--model_variant resnet_v1_101_beta
--atrous_rates 6
--atrous_rates 12
--atrous_rates 18
--output_stride 16
--decoder_output_stride 4
--eval_crop_size "513,513"
--checkpoint_dir TRAIN_21_classes
--vis_logdir VIS_21_classes
--dataset pascal_voc_seg
--dataset_dir tfrecord_21_classes
--max_number_of_evaluations 1
--save_softmax 1
1> VIS_21_classes.txt 2>&1

Generate part-level tfrecords

To generate the tfrecords of the Pascal-Part-58 with softmax contained inside:

python -u build_voc2012_data.py
--image_folder dataset/RGB
--semantic_segmentation_folder dataset/label58/gray/all
--softmax_folder VIS_21_classes/softmax_results
--load_softmax 1
--list_folder dataset
--output_dir tfrecord_58_parts

Perform Training

The commands to perform training can be found in the *.job or *.slurm files present in the zip archive downloaded earlier.

For instance, the command to train the complete model (GMNet) on the Pascal-Part-58 is:

python -u train.py
--logtostderr
--train_split train
--model_variant resnet_v1_101_beta
--atrous_rates 6
--atrous_rates 12
--atrous_rates 18
--output_stride 16
--decoder_output_stride 4
--train_crop_size "513,513"
--base_learning_rate 0.005
--train_batch_size 10
--training_number_of_steps 50000
--dataset pascal_voc_seg_58_parts
--tf_initial_checkpoint pretrained/imagenet/resnet_v1_101_2018_05_04/model.ckpt
--train_logdir TRAIN_58_parts
--dataset_dir tfrecord_58parts_complete
--model_softmax 1
--graph_loss 1
--weighted_graph 1
--class_dilation_kernel 2
--graph_lambda_loss 0.1
--graph_loss_type 'mean_squared_error'
--aux_loss 1
--aux_lambda_loss 0.0001
1> TRAIN_58_parts.txt 2>&1

Perform Evaluation and Visualization

The command to evaluate the complete model (GMNet) on the Pascal-Part-58 is:

python -u eval.py
--logtostderr
--eval_split val
--model_variant resnet_v1_101_beta
--atrous_rates 6
--atrous_rates 12
--atrous_rates 18
--output_stride 16
--decoder_output_stride 4
--eval_crop_size "513,513"
--checkpoint_dir TRAIN_58_parts
--eval_logdir EVAL_58_parts
--dataset pascal_voc_seg_58_parts
--dataset_dir tfrecord_58parts_complete
--max_number_of_evaluations 1
--model_softmax 1
1> EVAL_58_parts.txt 2>&1

To visualize the part-level predictions, instead, the command is:

python -u vis_parts.py
--logtostderr
--eval_split val
--model_variant resnet_v1_101_beta
--atrous_rates 6
--atrous_rates 12
--atrous_rates 18
--output_stride 16
--decoder_output_stride 4
--eval_crop_size "513,513"
--checkpoint_dir TRAIN_58_parts
--vis_logdir VIS_58_parts
--dataset pascal_voc_seg_58_parts
--dataset_dir tfrecord_58parts_softmax
--max_number_of_evaluations 1
--model_softmax 1
1> VIS_58_parts.txt 2>&1

Cite the paper

If you use this repository or you find our work useful, please consider to cite:

   @inProceedings{michieli2020gmnet,
   author = {Michieli, Umberto and Borsato, Edoardo and Rossi, Luca and Zanuttigh, Pietro},
   title  = {GMNet: Graph Matching Network for Large Scale Part Semantic Segmentation in the Wild},
   booktitle = {European Conference on Computer Vision (ECCV)},
   year      = {2020},
   month     = {August}
   }

Acknowledgments

Our code is derived from the official Tensorflow implementation of the Deeplab v3.

The dataset is derived from the Pascal-Part proposed in Chen et al., "Detect What You Can: Detecting and Representing Objects using Holistic Models and Body Parts", CVPR 2014.

We also acknowledge the work of Zhao et al. "Multi-class Part Parsing with Joint Boundary-Semantic Awareness", ICCV 2019, for providing the 58 labels split (Pascal-Part-58).

Remember to cite also their work if you use this code.

License

Apache License 2.0

gmnet's People

Stargazers

 avatar Zhang Tianbo avatar Beluuuuuuga avatar  avatar zhoudaxia avatar 爱可可-爱生活 avatar  avatar Researcher.YuanYuhui avatar  avatar Whiteloran avatar Jaedong Hwang avatar Marco Toldo avatar Kevin Stephen avatar  avatar free_wind avatar stanley avatar  avatar Honggui avatar  avatar An-zhi WANG avatar Massimiliano Mancini avatar Xxxia96 avatar Umberto Michieli avatar Ellery Queen avatar wuyujack (Mingfu Liang) avatar Fabio Pizzati avatar Luca Rossi avatar

Watchers

James Cloos avatar Pietro Zanuttigh avatar Umberto Michieli avatar

Forkers

cv-ip summer2474

gmnet's Issues

What does tfrecord_58parts_complete directory containe?

Hi Umberto,

Thank you for sharing your code.

I'm trying to perform training but I've gotten an error which I think related to the dataset directory. So, could you clarify what tfrecord_58parts_complete should contain?

python -u train.py --logtostderr --train_split train --model_variant resnet_v1_101_beta --atrous_rates 6 --atrous_rates 12 --atrous_rates 18 --output_stride 16 --decoder_output_stride 4 --train_crop_size "513,513" --base_learning_rate 0.005 --train_batch_size 10 --training_number_of_steps 50000 --dataset pascal_voc_seg_58_parts --tf_initial_checkpoint pretrained/imagenet/resnet_v1_101_2018_05_04/model.ckpt --train_logdir TRAIN_58_parts --dataset_dir tfrecord_58parts_complete --model_softmax 1 --graph_loss 1 --weighted_graph 1 --class_dilation_kernel 2 --graph_lambda_loss 0.1 --graph_loss_type 'mean_squared_error' --aux_loss 1 --aux_lambda_loss 0.0001 1> TRAIN_58_parts.txt 2>&1

When I set the dataset_dir to tfrecord_58_parts I get the following error:

INFO:tensorflow:Starting Queues. INFO:tensorflow:Error reported to Coordinator: Expected image (JPEG, PNG, or GIF), got empty file [[{{node cond_2/DecodePng}}]] [[node IteratorGetNext (defined at deeplab/train.py:481) ]] [[node while_1/while/SparseToDense (defined at /home/usr/models/GMNet/GMNet-master/Deeplab/research/deeplab/utils/train_utils.py:115) ]]

Segmentation Fault(Core Dumped) during evaluation

First, I would like to thank you for your work!
I have successfully trained the model using the tfrecords files provided and am now evaluating using the validation tfrecords.
I get the following error suring evaluation.

INFO:tensorflow:Waiting for new checkpoint at /ssd_scratch/cvit/kevins99/TRAIN_58_parts/ INFO:tensorflow:Found new checkpoint at /ssd_scratch/cvit/kevins99/TRAIN_58_parts/model.ckpt-12500 INFO:tensorflow:Graph was finalized. 2021-06-22 14:27:13.781293: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2021-06-22 14:27:14.822512: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x55d904617bd0 executing computations on platform CUDA. Devices: 2021-06-22 14:27:14.822555: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): GeForce RTX 2080 Ti, Compute Capability 7.5 2021-06-22 14:27:14.845026: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2400015000 Hz 2021-06-22 14:27:14.845787: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x55d904b9cad0 executing computations on platform Host. Devices: 2021-06-22 14:27:14.845825: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): <undefined>, <undefined> 2021-06-22 14:27:14.846022: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties: name: GeForce RTX 2080 Ti major: 7 minor: 5 memoryClockRate(GHz): 1.545 pciBusID: 0000:03:00.0 totalMemory: 10.76GiB freeMemory: 10.60GiB 2021-06-22 14:27:14.846047: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0 2021-06-22 14:27:14.847107: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix: 2021-06-22 14:27:14.847121: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0 2021-06-22 14:27:14.847144: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0: N 2021-06-22 14:27:14.847235: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10312 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2080 Ti, pci bus id: 0000:03:00.0, compute capability: 7.5) WARNING:tensorflow:From /home2/kevins99/anaconda3/envs/gmnet-tf/lib/python3.6/site-packages/tensorflow/python/training/saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version. Instructions for updating: Use standard file APIs to check for files with this prefix. INFO:tensorflow:Restoring parameters from /ssd_scratch/cvit/kevins99/TRAIN_58_parts/model.ckpt-12500 INFO:tensorflow:Running local_init_op. INFO:tensorflow:Done running local_init_op. INFO:tensorflow:Starting evaluation at 2021-06-22-08:57:20 Segmentation fault (core dumped)
My set up information is as follows:
CUDA: 10.2
CudNN: 7.6.5-cuda-10.2
Tensorflow-gpu: 1.13.2

I'd be much obliged if you could help me with this error.
Thank you!

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.