Code Monkey home page Code Monkey logo

scene-graph-tf-release's Introduction

Scene Graph Generation by Iterative Message Passing

Scene Graph prediction samples

About this repository

This repository contains an implementation of the models introduced in the paper Scene Graph Generation by Iterative Message Passing by Xu et al. The model taks an image and a graph proposal as input and predicts the object and relationship categories in the graph. The network is implemented using TensorFlow and the rest of the framework is in Python. Because the model is built directly on top of Faster-RCNN by Ren et al, a substantial amount of data processing code is adapted from the py-faster-rcnn repository.

Citing this work

If you find this work useful in your research, please consider citing:

@inproceedings{xu2017scenegraph,
  title={Scene Graph Generation by Iterative Message Passing},
  author={Xu, Danfei and Zhu, Yuke and Choy, Christopher and Fei-Fei, Li},
  booktitle={Computer Vision and Pattern Recognition (CVPR)},
  year={2017}
 }

Project page

The project page is available at http://cs.stanford.edu/~danfei/scene-graph/.

Prerequisites

  1. The framework does not include a regional proposal network implementation. A RoI proposal database pre-extracted using the py-faster-rcnn framework is available for download.
  2. You need CUDA-compatible GPUs to run the framework. A CPU-compatible version will be released soon.
  3. You need at least 320 GB of free space to store the processed VisualGenome image dataset. A training script that reads image files directly will be released in the future. However, if you just want to test/visualize some sample predictions, you may download a subset of the processed dataset (mini-vg) following the instruction or the "Quick Start" section. The subset takes ~4GB of space.

Dependencies

To get started with the framework, install the following dependencies:

  1. It is recommended that you install everything in an Anaconda environment, i.e., install Anaconda and run

    conda create -n sence-graph python=2.7
    source activate scene-graph
    
  2. Run pip install -r requirements.txt to install all the requirement except TensorFlow and CUDA. Follow the provided URL to install TensorFlow r0.11 (0.10 and 0.12 also works).

The code has not been tested on TensorFlow 1.0 and above, but may potentially work once you convert all TF-related code using the offical transition script.

Compile libraries

  1. After you have installed all the dependencies, run the following command to compile nms and bbox libraries.
cd lib
make
  1. Follow this this instruction to see if you can use the pre-compiled roi-pooling custom op or have to compile the op by yourself.

Quick Start

  1. Make sure you have installed all the dependencies and compiled the libraries.

  2. Run the download.sh script to download the mini-vg dataset and a model checkpoint.

    ./download.sh

  3. Run the following command to visualize a predicted scene graph. Set GPU_ID to the ID of the GPU you want to use, e.g. 0.

    ./experiments/scripts/test.sh mini-vg -1 \
                                  dual_graph_vrd_final 2 \
                                  checkpoints/dual_graph_vrd_final_iter2.ckpt \
                                  viz_cls \
                                  GPU_ID
    

Dataset

The scene graph dataset used in the paper is the VisualGenome dataset, although the framework can work with any scene graph dataset if converted to the desired format. Please refer to the dataset README for further instructions on converting the VG dataset into the desired format or downloading pre-processed datasets.

Train a model

Follow the following steps to train a model:

  1. Prepare or download the full dataset.

  2. Download a Faster-RCNN model pretrained on the MS-COCO dataset and save the model to data/pretrained/.

  3. Edit the training script experiments/scripts/train.sh such that all paths agree with the files on your file system.

  4. To train the final model with inference iterations = 2, run:

    ./experiments/scripts/train.sh dual_graph_vrd_final 2 CHECKPOINT_DIRECTORY GPU_ID

The program saves a checkpoint to checkpoints/CHECKPOINT_DIRECTORY/ every 50000 iterations. Training a full model on a desktop with Intel i7 CPU, 64GB memory, and a TitanX graphics card takes around 20 hours. You may use tensorboard to visualize the training process. By default, the tf log directory is set to checkpoints/CHECKPOINT_DIRECTORY/tf_logs/.

Evaluate a model

Follow the following steps to evaluate a model:

  1. Prepare or download the full dataset or the mini-vg dataset.

  2. If you wish to evaluate a pre-trained model, first download a checkpoint in the "Checkpoints" section.

  3. Edit the evaluation script experiments/scripts/test.sh such that all paths agree with the files on your file system.

  4. To evaluate the final model with inference iterations = 2 using 100 images in the test set of the full VG dataset (use mini-vg for the mini VG dataset), run

    ./experiments/scripts/test.sh vg 100 dual_graph_vrd_final 2 CHECKPOINT_PATH(.ckpt) all GPU_ID

Note that to reproduce the results as presented the paper, you have to evaluate the entire test set by setting the number of images to -1. The evaluation process takes around 10 hours. Setting the evaluation mode to all is to evaluate the models on all three tasks, i.e., pred_cls, sg_cls, sg_det. You can also set the evaluation mode to individual tasks.

Visualize a predicted scene graph

Follow the following steps to visualize a scene graph predicted by the model:

  1. Prepare or download the full dataset or the mini-vg dataset.

  2. If you wish to evaluate a pre-trained model, first download a checkpoint in the "Checkpoints" section.

  3. Edit the evaluation script experiments/scripts/test.sh such that all paths agree with the files on your file system.

  4. To visualize the predicted graph of the first 100 images in the test set of the full VG dataset (use mini-vg for the mini VG dataset), run

    ./experiments/scripts/test.sh vg 100 dual_graph_vrd_final 2 CHECKPOINT_PATH(.ckpt) viz_cls GPU_ID

The viz_cls mode assumes ground truth bounding boxes and predicts the predicted object and relationship labels, which is of the same setting as the sg_cls task. viz_det mode uses the proposed bounding box from the regional proposal network as the object proposals, which is of the same setting as the sg_det task.

Checkpoints

A TensorFlow checkpoint of the final model trained with 2 inference iterations:

dual_graph_vrd_final_iter2_checkpoint.zip

License

MIT License

scene-graph-tf-release's People

Contributors

danfeix avatar francoispl 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

scene-graph-tf-release's Issues

CPU version

It is mentioned that "the CPU version will be released soon".
Is it already released? or is there any quick way to run the code using CPU only?
Thanks.

Unable to generate the file proposals.h5

Dear author, hello, I want to know that you mentioned to generate proposals.h5 file in this paper. I am interested in how to generate this file. Could you help me, please? Thank you very much.

Using the predicate classification task

Hello @danfeiX

I have bounding box proposals and object categories for a dataset and I am trying to evaluate the predicate classification task for the same. I was wondering if there is any guide on how to go about this task. I am confused regarding the inputs that I need to be feeding to the model in this case and what sort of a format I need to be generating for the same.

If anyone can share their insight on this, it would be very helpful!
Thank you!

When recreating the VG-SGG file, the number of objects and relations is different

Hi All,

I'm trying to add some data to the VG-SGG file, and I thought the easiest way was to try and recreate the processed data. However, when I do this, the number of objects and relations that are remaining changes.

I have no clue why this is happening. Should I change some settings? Or is something else happening?

Thanks for the help and any insight you can give!

getting the vert features

Hello @danfeiX
I am trying to get the features for the each vert in an image. I figured it is passed through the vert_factor but when I save the vert_factor to a np.ndarry it's only a 512d vector for one image. I suspect it's only for one bounding_box?

If someone can give any insight on how to get the features for all vert of an image, would be much appreciated.

Ran out of memory trying to allocate 117.19MiB. | Resource exhausted: OOM when allocating tensor.

On running this command:
./experiments/scripts/test.sh mini-vg -1
dual_graph_vrd_final 2
checkpoints/dual_graph_vrd_final_iter2.ckpt
viz_cls
0

I was getting Error:
.
.
I tensorflow/core/common_runtime/bfc_allocator.cc:696] Sum Total of in-use chunks: 1.42GiB
I tensorflow/core/common_runtime/bfc_allocator.cc:698] Stats:
Limit: 1616576512
InUse: 1519864576
MaxInUse: 1519864576
NumAllocs: 148
MaxAllocSize: 467140864

W tensorflow/core/common_runtime/bfc_allocator.cc:270] ************____***************************xxxxx
W tensorflow/core/common_runtime/bfc_allocator.cc:271] Ran out of memory trying to allocate 117.19MiB. See logs for memory state.
W tensorflow/core/framework/op_kernel.cc:968] Resource exhausted: OOM when allocating tensor with shape[1,64,600,800]
Traceback (most recent call last):
File "./tools/test_net.py", line 91, in
viz_net(args.network_name, args.model, imdb, args.test_mode)
File "/home/neeraj/scene-graph-TF-release/tools/../lib/fast_rcnn/visualize.py", line 157, in viz_net
bbox_reg, [inference_iter])
File "/home/neeraj/scene-graph-TF-release/tools/../lib/fast_rcnn/test.py", line 142, in im_detect
ops_value = sess.run(ops, feed_dict=feed_dict)
File "/home/neeraj/anaconda3/envs/scene-graph/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 717, in run
run_metadata_ptr)
File "/home/neeraj/anaconda3/envs/scene-graph/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 915, in _run
feed_dict_string, options, run_metadata)
File "/home/neeraj/anaconda3/envs/scene-graph/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 965, in _do_run
target_list, options, run_metadata)
File "/home/neeraj/anaconda3/envs/scene-graph/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 985, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors.ResourceExhaustedError: OOM when allocating tensor with shape[1,64,600,800]
[[Node: conv1_2/Conv2D = Conv2D[T=DT_FLOAT, data_format="NHWC", padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/gpu:0"](conv1_1/conv1_1, conv1_2/weights/read)]]
[[Node: Cast_3/_147 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_78_Cast_3", tensor_type=DT_DOUBLE, _device="/job:localhost/replica:0/task:0/cpu:0"]]

Caused by op u'conv1_2/Conv2D', defined at:
File "./tools/test_net.py", line 91, in
viz_net(args.network_name, args.model, imdb, args.test_mode)
File "/home/neeraj/scene-graph-TF-release/tools/../lib/fast_rcnn/visualize.py", line 111, in viz_net
net.setup()
File "/home/neeraj/scene-graph-TF-release/tools/../lib/networks/models.py", line 178, in setup
self._vgg_conv()
File "/home/neeraj/scene-graph-TF-release/tools/../lib/networks/models.py", line 37, in _vgg_conv
.conv(3, 3, 64, 1, 1, name='conv1_2')
File "/home/neeraj/scene-graph-TF-release/tools/../lib/networks/network.py", line 25, in layer_decorated
layer_output = op(self, layer_input, *args, **kwargs)
File "/home/neeraj/scene-graph-TF-release/tools/../lib/networks/network.py", line 135, in conv
conv = convolve(input, kernel)
File "/home/neeraj/scene-graph-TF-release/tools/../lib/networks/network.py", line 126, in
convolve = lambda i, k: tf.nn.conv2d(i, k, [1, s_h, s_w, 1], padding=padding)
File "/home/neeraj/anaconda3/envs/scene-graph/lib/python2.7/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 394, in conv2d
data_format=data_format, name=name)
File "/home/neeraj/anaconda3/envs/scene-graph/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 749, in apply_op
op_def=op_def)
File "/home/neeraj/anaconda3/envs/scene-graph/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2380, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/home/neeraj/anaconda3/envs/scene-graph/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1298, in init
self._traceback = _extract_stack()

ResourceExhaustedError (see above for traceback): OOM when allocating tensor with shape[1,64,600,800]
[[Node: conv1_2/Conv2D = Conv2D[T=DT_FLOAT, data_format="NHWC", padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/gpu:0"](conv1_1/conv1_1, conv1_2/weights/read)]]
[[Node: Cast_3/_147 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_78_Cast_3", tensor_type=DT_DOUBLE, _device="/job:localhost/replica:0/task:0/cpu:0"]]

Please Help !! @danfeiX @FrancoisPl

Extracting output features of the GRU

Hi,

I was trying to extract the output of the edge/node GRUs (just the edge_factor/vert_factor before update_inference, at

vert_in = vert_factor
. But when I save and retrieve it, it only returns a feature of 512 dimension, instead of the num_roi/num_rel * 512. Is there anyway in Tensorflow to gather this feature across all the dimensions ?

Out of memory when training with a TITAN X

I met with the OOM problem when training with a TITAN X graphic card. The log is as follows:

I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (256): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (512): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (1024): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (2048): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (4096): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (8192): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (16384): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (32768): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (65536): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (131072): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (262144): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (524288): Total Chunks: 1, Chunks in use: 0 905.2KiB allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (1048576): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (2097152): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (4194304): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (8388608): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (16777216): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (33554432): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (67108864): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (134217728): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:643] Bin (268435456): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:660] Bin for 392.00MiB was 256.00MiB, Chunk State:
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a300000 of size 1280
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a300500 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a300600 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a300700 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a300800 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a300900 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a300a00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a300b00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a300c00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a300d00 of size 512
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a300f00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a301000 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a301100 of size 512
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a301300 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a301400 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a301500 of size 1024
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a301900 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a301a00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a301b00 of size 1024
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a301f00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a302000 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a302100 of size 1024
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a302500 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a302600 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a302700 of size 2048
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a302f00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a303000 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a303100 of size 2048
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a303900 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a303a00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a303b00 of size 2048
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a304300 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a304400 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a304500 of size 2048
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a304d00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a304e00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a304f00 of size 2048
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a305700 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a305800 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a305900 of size 2048
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a306100 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a306200 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a306300 of size 16384
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a30a300 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a30a400 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a30a500 of size 16384
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a30e500 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a30e600 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a30e700 of size 16384
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a312700 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a312800 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a312900 of size 16384
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a316900 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a316a00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a316b00 of size 2048
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a317300 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a317400 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a317500 of size 2048
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a317d00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a317e00 of size 4096
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a318e00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a318f00 of size 2048
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a319700 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a319800 of size 4096
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31a800 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31a900 of size 2048
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31b100 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31b200 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31b300 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31b400 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31b500 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31b600 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31b700 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31b800 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31b900 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31ba00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31bb00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31bc00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31bd00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31be00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31bf00 of size 768
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31c200 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31c300 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31c400 of size 2560
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31ce00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31cf00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31d000 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31d100 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31d200 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31d300 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31d400 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31d500 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31d600 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31d700 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31d800 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31d900 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:678] Chunk at 0x130a31da00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:687] Free at 0x130a31db00 of size 926976
I tensorflow/core/common_runtime/bfc_allocator.cc:693] Summary of in-use Chunks by size:
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 73 Chunks of size 256 totalling 18.2KiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 2 Chunks of size 512 totalling 1.0KiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 1 Chunks of size 768 totalling 768B
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 3 Chunks of size 1024 totalling 3.0KiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 1 Chunks of size 1280 totalling 1.2KiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 10 Chunks of size 2048 totalling 20.0KiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 1 Chunks of size 2560 totalling 2.5KiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 2 Chunks of size 4096 totalling 8.0KiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 4 Chunks of size 16384 totalling 64.0KiB
I tensorflow/core/common_runtime/bfc_allocator.cc:700] Sum Total of in-use chunks: 118.8KiB
I tensorflow/core/common_runtime/bfc_allocator.cc:702] Stats:
Limit: 198770688
InUse: 121600
MaxInUse: 121600
NumAllocs: 97
MaxAllocSize: 16384

W tensorflow/core/common_runtime/bfc_allocator.cc:274] ************________________________________________________________________________________________
W tensorflow/core/common_runtime/bfc_allocator.cc:275] Ran out of memory trying to allocate 392.00MiB. See logs for memory state.
W tensorflow/core/framework/op_kernel.cc:965] Internal: Dst tensor is not initialized.
E tensorflow/core/common_runtime/executor.cc:390] Executor failed to create kernel. Internal: Dst tensor is not initialized.
[[Node: zeros_6 = Constdtype=DT_FLOAT, value=Tensor<type: float shape: [25088,4096] values: [0 0 0]...>, _device="/job:localhost/replica:0/task:0/gpu:0"]]

_viz_scene_graph show box defect

from 100 to 108 in scene-graph-TF-release/lib/datasets/viz.py

for i, bbox in enumerate(rois):
if int(labels[i]) == 0 and i not in rel_inds:
continue
ax.add_patch(
plt.Rectangle((bbox[0], bbox[1]),
bbox[2] - bbox[0],
bbox[3] - bbox[1], fill=False,
edgecolor='red', linewidth=3.5)
)

actuallly, there are 150 bbox generated by Regression from every rpn roi, each class has one box, so this should be as follows:
for i, bbox in enumerate(rois):
if int(labels[i]) == 0 and i not in rel_inds:
continue$
offset = labels[i]*4
ax.add_patch(
plt.Rectangle((bbox[offset+0], bbox[offset+1]),
bbox[offset+2] - bbox[offset+0],
bbox[offset+3] - bbox[offset+1], fill=False,
edgecolor='red', linewidth=3.5)
)

this will show right box for highest score.

What does this file proposals.h contain?

hi @danfeiX @FrancoisPl

Is it convenient for you to release the code that generated proposal.h? Or is it convenient to tell what the documents ( e.g. imscales, im_to_roi_idx, num_rois, rpn_rois,rpn_scores those are included in proposals.h) are respectively?

OOM during VG training

Hi @danfeiX and everyone,

I'm running into out-of-memory errors during training on the complete VG dataset. Given the 150k iterations recommended, each of the workers crashes with the same error (below) at various iterations in the training process. The last worker survives until about 58k iterations, after which the program freezes and produces no further output.

The error:

Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/process.py", line 267, in _bootstrap
    self.run()
  File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/../scene-graph-TF-release/tools/../lib/roi_data_layer/data_runner.py", line 37, in _worker_main
    sample = self._task_func(task)
  File "/../scene-graph-TF-release/tools/../lib/roi_data_layer/layer.py", line 50, in _get_next_minibatch
    minibatch_db = self.imdb.add_rpn_rois(minibatch_db)
  File "/../scene-graph-TF-release/tools/../lib/datasets/vg_hdf5.py",
 line 159, in add_rpn_rois
    rpn_roidb = self._load_rpn_roidb(gt_roidb)
  File "/../scene-graph-TF-release/tools/../lib/datasets/vg_hdf5.py",
 line 173, in _load_rpn_roidb
    roidb = self.create_roidb_from_box_list(box_list, gt_roidb)
  File "/../scene-graph-TF-release/tools/../lib/datasets/imdb.py", line 73, in create_roidb_from_box_list
    gt_boxes.astype(np.float))
  File "utils/bbox.pyx", line 29, in utils.cython_bbox.bbox_overlaps
    cdef np.ndarray[DTYPE_t, ndim=2] overlaps = np.zeros((N, K), dtype=DTYPE)
MemoryError

What I have tried:

  • Decreasing the batch size
  • Ensuring that tf.ConfigProto().gpu_options.allow_growth is set to True

Specs:
CPU: Intel Xeon CPU E5-2698 v4 @ 2.20GHz
GPU: Tesla V100-SXM2-16GB
RAM: 500 GB

My questions:

  • Does anyone have a solution for this?
  • If not, does anyone know if a model checkpoint obtained at ~49k iterations would be sufficient? How much performance improvement is gained over those last 100k iterations?
  • Is anyone able to train this model? If so, what are the specs of your machine?

Thank you for your time! I would greatly appreciate any answers or comments. I will update this if I have any insights.

Unable to run: errors seemingly related to roidb data preparation

Dear Danfei,

I keep running into the following errors when using the code. Could you help with this issue please?


/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gradients.py:90: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
"Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
Process Process-2:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/home/dl/scene-graph-TF-master/tools/../lib/roi_data_layer/data_runner.py", line 37, in _worker_main
sample = self._task_func(task)
File "/home/dl/scene-graph-TF-master/tools/../lib/roi_data_layer/layer.py", line 53, in _get_next_minibatch
self.bbox_stds)
File "/home/dl/scene-graph-TF-master/tools/../lib/roi_data_layer/roidb.py", line 83, in add_bbox_regression_targets
num_classes = roidb[0]['gt_overlaps'].shape[1]
IndexError: list index out of range
Process Process-3:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
Loading pretrained model weights from data/pretrained/coco_vgg16_faster_rcnn_final.npy
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/home/dl/scene-graph-TF-master/tools/../lib/roi_data_layer/data_runner.py", line 37, in _worker_main
sample = self._task_func(task)
File "/home/dl/scene-graph-TF-master/tools/../lib/roi_data_layer/layer.py", line 53, in _get_next_minibatch
self.bbox_stds)
File "/home/dl/scene-graph-TF-master/tools/../lib/roi_data_layer/roidb.py", line 83, in add_bbox_regression_targets
num_classes = roidb[0]['gt_overlaps'].shape[1]
IndexError: list index out of range
Process Process-4:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/home/dl/scene-graph-TF-master/tools/../lib/roi_data_layer/data_runner.py", line 37, in _worker_main
sample = self._task_func(task)
File "/home/dl/scene-graph-TF-master/tools/../lib/roi_data_layer/layer.py", line 53, in _get_next_minibatch
self.bbox_stds)
File "/home/dl/scene-graph-TF-master/tools/../lib/roi_data_layer/roidb.py", line 83, in add_bbox_regression_targets
num_classes = roidb[0]['gt_overlaps'].shape[1]
IndexError: list index out of range


This is what I did:

  1. download the repository (denote the path as SG_ROOT), the 'mini-vg' dataset (plus the additional bbox_distribution.npy), rename it as 'vg' and place it under [SG_ROOT]/data/
  2. 'make' it accodingly, and specify the 'filename' in roi_pooling_op.py to the absolute address '../roi_pooling_op_gpu_cuda8.so' for correct tf.load_op_library (no NotFoundError occured)
  3. download 'coco_vgg16_faster_rcnn_final.npy' and place it under [SG_ROOT]/data/pretrained/
  4. hit '[SG_ROOT]/experiments/scripts/train.sh dual_graph_vrd_final 2 checkpoints 0'

FYI, I am using tensorflow 0.11.0 with CUDA 8.0.

Could you please give a clue on how to fix this issue? Thanks very much!

Evaluate/visualize an image outside VG dataset

Hello @danfeiX
I was wondering if there is a way to evaluate image(s) that are not in the VG dataset using this framework. Currently, using test.sh with the pre-trained model from this repository, it allows passing single/multiple VG images from the imdb_1024.h5 which requires associated scene graph database+metadata, ROI proposals+distributuion.

If anyone can share their insight on this would be most helpful.

OSError: [Errno 2] No such file or directory--subprocess.Popen(['xdg-open', filepath])

hi, could u help me solve this problem, tks very much! @danfeiX

Loading model weights from checkpoints/dual_graph_vrd_final_iter2.ckpt
=======================VIZ INFERENCE Iteration = 1
=======================VIZ MODES = viz_det
Traceback (most recent call last):
File "./tools/test_net.py", line 91, in
viz_net(args.network_name, args.model, imdb, args.test_mode)
File "/data/scene-graph-TF-release/tools/../lib/fast_rcnn/visualize.py", line 163,in viz_net
gt_to_pred, roidb[im_i])
File "/data/scene-graph-TF-release/tools/../lib/fast_rcnn/visualize.py", line 69, in draw_graph_pred
graph_dict = draw_scene_graph(cls_pred, pred_inds, rel_pred)
File "/data/scene-graph-TF-release/tools/../lib/datasets/viz.py", line 29, in draw_scene_graph
return draw_graph(viz_labels, viz_rels, cfg)
File "/data/scene-graph-TF-release/tools/../lib/datasets/viz.py", line 63, in draw_graph
u.view()
File "/usr/local/miniconda3/envs/dl/lib/python2.7/site-packages/graphviz/files.py", line 203, in view
cleanup=cleanup)
File "/usr/local/miniconda3/envs/dl/lib/python2.7/site-packages/graphviz/files.py", line 182, in render
self._view(rendered, self._format)
File "/usr/local/miniconda3/envs/dl/lib/python2.7/site-packages/graphviz/files.py", line 218, in _view
view_method(filepath)
File "/usr/local/miniconda3/envs/dl/lib/python2.7/site-packages/graphviz/backend.py", line 228, in view_unixoid
subprocess.Popen(['xdg-open', filepath])
File "/usr/local/miniconda3/envs/dl/lib/python2.7/subprocess.py", line 394, in init
errread, errwrite)
File "/usr/local/miniconda3/envs/dl/lib/python2.7/subprocess.py", line 1047, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

how to classify BG relationships

HI:
I have a question bout your code in flag ignore_bg. I found that you set that as True when classify relationships.So I want to konw how could classify BG relationships.Thanks!

roi_pool problem

when perform code in lib.networks.models._vgg_fc

feed_in, dim = (input, int(input_shape[-1]))

occur this problem:

feed_in, dim = (input, int(input_shape[-1]))
TypeError: __int__ returned non-int (type NoneType)
We've got an error while stopping in post-mortem: <class 'KeyboardInterrupt'>

I think caused by roi_pool. Hope you could help me to solve it.

When running scene-graph-tf : TypeError: __int__ returned non-int (type NoneType)

When I follow the introduction and run the test demo :
./experiments/scripts/test.sh mini-vg -1
dual_graph_vrd_final 2
checkpoints/dual_graph_vrd_final_iter2.ckpt
viz_cls
0
I meet with the error : "TypeError: int returned non-int (type NoneType) "
Here is the log, Are there any friends who can help?

./experiments/scripts/test.sh mini-vg -1 dual_graph_vrd_final 2 checkpoints/dual_graph_vrd_final_iter2.ckpt viz_cls 0
++ set -e
++ export PYTHONUNBUFFERED=True
++ PYTHONUNBUFFERED=True
++ DATASET=mini-vg
++ NUM_IM=-1
++ NET=dual_graph_vrd_final
++ INFERENCE_ITER=2
++ WEIGHT_FN=checkpoints/dual_graph_vrd_final_iter2.ckpt
++ TEST_MODE=viz_cls
++ GPU_ID=0
++ CFG_FILE=experiments/cfgs/sparse_graph.yml
++ case $DATASET in
++ ROIDB=mini_VG-SGG
++ RPNDB=mini_proposals
++ IMDB=mini_imdb_1024
++ export CUDA_VISIBLE_DEVICES=0
++ CUDA_VISIBLE_DEVICES=0
++ python ./tools/test_net.py --gpu 0 --weights checkpoints/dual_graph_vrd_final_iter2.ckpt --imdb mini_imdb_1024.h5 --roidb mini_VG-SGG --rpndb mini_proposals.h5 --cfg experiments/cfgs/sparse_graph.yml --network dual_graph_vrd_final --inference_iter 2 --test_size -1 --test_mode viz_cls
Called with args:
Namespace(cfg_file='experiments/cfgs/sparse_graph.yml', gpu_id=0, imdb='mini_imdb_1024.h5', inference_iter=2, model='checkpoints/dual_graph_vrd_final_iter2.ckpt', network_name='dual_graph_vrd_final', output_dir=None, roidb='mini_VG-SGG', rpndb='mini_proposals.h5', test_mode='viz_cls', test_size=-1, wait=True)
Using config:
{'DATA_DIR': '/share/UserFolder/zhpe/scene-graph-TF-release-master/data',
'DEDUP_BOXES': 0.0625,
'EPS': 1e-14,
'GPU_ID': 0,
'PIXEL_MEANS': array([[[ 102.9801, 115.9465, 122.7717]]]),
'RNG_SEED': 3,
'ROOT_DIR': '/share/UserFolder/zhpe/scene-graph-TF-release-master',
'TEST': {'BBOX_REG': True,
'FG_THRESH': 0.5,
'HAS_RPN': False,
'INFERENCE_ITER': 2,
'MAX_SIZE': 1000,
'NUM_PROPOSALS': 50,
'PROPOSAL_NMS': 0.3,
'SCALES': [600],
'USE_RPN_DB': True},
'TRAIN': {'ASPECT_GROUPING': True,
'BATCH_SIZE': 256,
'BBOX_INSIDE_WEIGHTS': [1.0, 1.0, 1.0, 1.0],
'BBOX_NORMALIZE_MEANS': [0.0, 0.0, 0.0, 0.0],
'BBOX_NORMALIZE_STDS': [0.1, 0.1, 0.2, 0.2],
'BBOX_NORMALIZE_TARGETS': True,
'BBOX_NORMALIZE_TARGETS_PRECOMPUTED': False,
'BBOX_REG': True,
'BBOX_TARGET_NORMALIZATION_FILE': 'data/vg/bbox_distribution.npy',
'BBOX_THRESH': 0.5,
'BG_THRESH_HI': 0.5,
'BG_THRESH_LO': 0.1,
'DISPLAY_FREQ': 10,
'FG_FRACTION': 0.5,
'FG_THRESH': 0.5,
'GAMMA': 0.1,
'IMS_PER_BATCH': 2,
'LEARNING_RATE': 0.001,
'MAX_SIZE': 1000,
'MOMENTUM': 0.9,
'NUM_NEG_RELS': 128,
'SCALES': [600],
'SNAPSHOT_FREQ': 50000,
'SNAPSHOT_INFIX': '',
'SNAPSHOT_PREFIX': '',
'STEPSIZE': 50000,
'SUMMARY_FREQ': 250,
'USE_FLIPPED': True,
'USE_RPN_DB': True},
'VG_DIR': '/share/UserFolder/zhpe/scene-graph-TF-release-master/data/vg'}
/gpu:0
split==2
2017-09-17 16:20:56.154149: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-09-17 16:20:56.154186: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-09-17 16:20:56.154194: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-09-17 16:20:56.154200: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-09-17 16:20:56.154206: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
2017-09-17 16:20:57.936868: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 0 with properties:
name: TITAN X (Pascal)
major: 6 minor: 1 memoryClockRate (GHz) 1.531
pciBusID 0000:02:00.0
Total memory: 11.90GiB
Free memory: 11.75GiB
2017-09-17 16:20:57.936961: I tensorflow/core/common_runtime/gpu/gpu_device.cc:961] DMA: 0
2017-09-17 16:20:57.936981: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0: Y
2017-09-17 16:20:57.937028: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: TITAN X (Pascal), pci bus id: 0000:02:00.0)
Tensor("ims:0", shape=(?, ?, ?, 3), dtype=float32)
Tensor("conv_out:0", shape=(?, ?, ?, 512), dtype=float32)
Tensor("rois:0", shape=(?, 5), dtype=float32)
[<tf.Tensor 'conv_out:0' shape=(?, ?, ?, 512) dtype=float32>, <tf.Tensor 'rois:0' shape=(?, 5) dtype=float32>]

Traceback (most recent call last):
File "./tools/test_net.py", line 91, in
viz_net(args.network_name, args.model, imdb, args.test_mode)
File "/share/UserFolder/zhpe/scene-graph-TF-release-master/tools/../lib/fast_rcnn/visualize.py", line 111, in viz_net
net.setup()
File "/share/UserFolder/zhpe/scene-graph-TF-release-master/tools/../lib/networks/models.py", line 179, in setup
self._vgg_fc()
File "/share/UserFolder/zhpe/scene-graph-TF-release-master/tools/../lib/networks/models.py", line 58, in _vgg_fc
.fc(4096, name='fc6')
File "/share/UserFolder/zhpe/scene-graph-TF-release-master/tools/../lib/networks/network.py", line 25, in layer_decorated
layer_output = op(self, layer_input, *args, **kwargs)
File "/share/UserFolder/zhpe/scene-graph-TF-release-master/tools/../lib/networks/network.py", line 222, in fc
feed_in, dim = (input, int(input_shape[-1]))
TypeError: int returned non-int (type NoneType)

Questions regarding VG-SGG.h5

Can someone help me understand what the values in ['relationships'] are? The number seems to go as high as the data size. How is this 2D array created? and how are these values linked with each other?
Any help would be useful. Thank you in advance!

==None should be is None

in lib/datasets/viz.py 76 lines
"if inds == None": should be fixed to be: "if inds is None"
== None sometimes will make error, program will shut down.

An error happened when I create VG-SGG.h5.

Traceback (most recent call last):
File "vg_to_roidb.py", line 639, in
main(args)
File "vg_to_roidb.py", line 570, in main
heights, widths, img_long_sizes)
File "vg_to_roidb.py", line 277, in encode_objects
encoded_boxes[k] = np.vstack(boxes)
File "/home/lkk/anaconda3/lib/python3.6/site-packages/numpy/core/shape_base.py", line 234, in vstack
return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
ValueError: need at least one array to concatenate

cuda/include/cuda.h No such file or directory

Hi,
I am trying to compile the op by myself and when I run
nvcc -std=c++11 -c -o roi_pooling_op_gpu.cu.o roi_pooling_op_gpu.cu.cc -I
$TF_INC -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC

I get the following error:
In file included from roi_pooling_op_gpu.cu.cc:10:0:
/home/medhini2/.local/lib/python2.7/site-packages/tensorflow/include/tensorflow/core/util/cuda_kernel_helper.h:24:31: fatal error: cuda/include/cuda.h: No such file or directory
#include "cuda/include/cuda.h"

How do I go about fixing this?

vg_hdf5.py read data defect

scene-graph-TF-release/lib/datasets/vg_hdf5.py

line 31: valid_mask = self.roi_h5['img_to_first_box'][:] > 0 should be
'valid_mask = self.roi_h5['img_to_first_box'][:] >= 0', because the first image has index of 0, and invalid index is actually set to be -1 in 'scene-graph-TF-release/data_tools/vg_to_roidb.py'
270 if im_to_first_obj[i] == obj_counter:
271 im_to_first_obj[i] = -1
272 im_to_last_obj[i] = -1

why tuple under function definition?

In models.py, there are lots of tuple-under-function style code.
for example, _vgg_fc()

 55     def _vgg_fc(self):
 56         (self.feed('conv_out', 'rois')
 57              .roi_pool(7, 7, 1.0/16, name='pool5')
 58              .fc(4096, name='fc6')
 59              .dropout(self.keep_prob, name='drop6')
 60              .fc(4096, name='fc7')
 61              .dropout(self.keep_prob, name='vgg_out'))

I wonder what is the different from the code below?

 55     def _vgg_fc(self):
 56         self.feed('conv_out', 'rois')
 57              .roi_pool(7, 7, 1.0/16, name='pool5')
 58              .fc(4096, name='fc6')
 59              .dropout(self.keep_prob, name='drop6')
 60              .fc(4096, name='fc7')
 61              .dropout(self.keep_prob, name='vgg_out')

Where do you separate Train/Val data?

According to the paper, you mentioned 70% data for training and 30% for testing. However, I cannot find you data separation in your code. It seems to me that you are testing using training data. Please clarify if I miss something.

Error when compilng RoiPoolingLayer

Hi I have tried both ways to compile the RoiPooingLayer. the first one has following error :

python -c 'import tensorflow as tf; tf.load_o
p_library("PARENT_DIR/scene-graph-TF-release-master/lib/roi_pooling_layer/roi_pooling_op_gpu_cuda8.so")'
Traceback (most recent call last):
File "<string>", line 1, in
File "TENSORFLOW_PATH/lib/python2.7/site-packages/tensorflow/python/framework/load_library.py", line 64, in load_op_library
None, None, error_msg, error_code)
tensorflow.python.framework.errors_impl.NotFoundError: TENSORFLOW_PATH/scene-graph-TF-release-master/lib/roi_pooling_layer/roi_pooling_op_gpu_cuda8.so: undefined symbol: _ZN10tensorflow11TensorShapeC1Ev

There are similar problems in TFFRCNN issue post(CharlesShang/TFFRCNN#2).
The solution for it is to add -D_GLIBCXX_USE_CXX11_ABI=0 g++ compile flag in make.sh, whereas in this version there is no make.sh. Then I tried to add this extra flag on sefl by myself. Then following error appears:

nvcc -std=c++11 -c -o roi_pooling_op_gpu.cu.o
roi_pooling_op_gpu.cu.cc -I $TF_INC -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC
roi_pooling_op_gpu.cu.cc:9:57: fatal error: tensorflow/core/user_ops/roi_pooling_op_gpu.h: No such file or directory
Note that I MANUALLY created .../user_ops/ and move every file under .../src/ to .../user_ops/. since there is no such folder before and maybe this is the problem.

Please help me out! Thanks !!!

How and where are the frequent objects and relationships selected?

I wonder from which version of Visual Genome are the frequent objects and relationships selected. Because I counted the occurrences myself but got totally different results as in VG-SGG-dicts.json. For example, for object 'man', I got 88886 instances from Visual Genome V1.0, rather than 54659. I tried all the three versions of the dataset, but fail to get a same result with VG-SGG-dicts.json.

TypeError: Boolean indexing array has incompatible shape

I got the following error, anybody has solution?

Traceback (most recent call last):
File "./tools/test_net.py", line 89, in
imdb = get_imdb(args.roidb, args.imdb, args.rpndb, split=2, num_im=args.test_size)
File "/home/jonas/桌面/scene-graph-TF-release/tools/../lib/datasets/factory.py", line 4, in get_imdb
return vg_hdf5('%s.h5'%roidb_name, '%s-dicts.json'%roidb_name, imdb_name, rpndb_name, split=split, num_im=num_im)
File "/home/jonas/桌面/scene-graph-TF-release/tools/../lib/datasets/vg_hdf5.py", line 42, in init
self.im_sizes = np.vstack([self.im_h5['image_widths'][split_mask],
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "/home/jonas/anaconda3/envs/py2.7/lib/python2.7/site-packages/h5py/_hl/dataset.py", line 553, in getitem
selection = sel.select(self.shape, args, dsid=self.id)
File "/home/jonas/anaconda3/envs/py2.7/lib/python2.7/site-packages/h5py/_hl/selections.py", line 72, in select
sel[arg]
File "/home/jonas/anaconda3/envs/py2.7/lib/python2.7/site-packages/h5py/_hl/selections.py", line 214, in getitem
raise TypeError("Boolean indexing array has incompatible shape")
TypeError: Boolean indexing array has incompatible shape

NotFoundError (see above for traceback): Tensor name "edge_rnn/gru_cell/candidate/bias" not found in checkpoint files checkpoints/dual_graph_vrd_final_iter2.ckpt

when loading checkpoint files, the error occors.

Loading model weights from checkpoints/dual_graph_vrd_final_iter2.ckpt
Traceback (most recent call last):
File "./tools/test_net.py", line 91, in
viz_net(args.network_name, args.model, imdb, args.test_mode)
File "/home/yzzc/Work/csl/scene-graph-TF-release/tools/../lib/fast_rcnn/visualize.py", line 114, in viz_net
saver.restore(sess, weight_name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1802, in restore
{self.saver_def.filename_tensor_name: save_path})
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 900, in run
run_metadata_ptr)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1135, in _run
feed_dict_tensor, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1316, in _do_run
run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1335, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.NotFoundError: Tensor name "edge_rnn/gru_cell/candidate/bias" not found in checkpoint files checkpoints/dual_graph_vrd_final_iter2.ckpt
[[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]
[[Node: save/RestoreV2/_13 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_18_save/RestoreV2", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"]]

Caused by op u'save/RestoreV2', defined at:
File "./tools/test_net.py", line 91, in
viz_net(args.network_name, args.model, imdb, args.test_mode)
File "/home/yzzc/Work/csl/scene-graph-TF-release/tools/../lib/fast_rcnn/visualize.py", line 113, in viz_net
saver = tf.train.Saver()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1338, in init
self.build()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1347, in build
self._build(self._filename, build_save=True, build_restore=True)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1384, in _build
build_save=build_save, build_restore=build_restore)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 835, in _build_internal
restore_sequentially, reshape)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 472, in _AddRestoreOps
restore_sequentially)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 886, in bulk_restore
return io_ops.restore_v2(filename_tensor, names, slices, dtypes)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_io_ops.py", line 1463, in restore_v2
shape_and_slices=shape_and_slices, dtypes=dtypes, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 3392, in create_op
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1718, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

NotFoundError (see above for traceback): Tensor name "edge_rnn/gru_cell/candidate/bias" not found in checkpoint files checkpoints/dual_graph_vrd_final_iter2.ckpt
[[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]
[[Node: save/RestoreV2/_13 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_18_save/RestoreV2", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"]]

How to get the roi proposals

For data preparation, it says that use the script provided by py-faster-rcnn to generate (4). RoI proposals: proposals.h5. I am wondering whether it should be fast-rcnn, since py-faster-rcnn doesn't need outside ROI proposals.

Tensor name "vert_rnn/gru_cell/gates/biases" not found in checkpoint files checkpoints/dual_graph_vrd_final_iter2.ckpt

I found the following error when running the quick start. Can you give some suggestion?

NotFoundError (see above for traceback): Tensor name "vert_rnn/gru_cell/gates/biases" not found in checkpoint files checkpoints/dual_graph_vrd_final_iter2.ckpt
[[Node: save/RestoreV2_56 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/RestoreV2_56/tensor_names, save/RestoreV2_56/shape_and_slices)]]
[[Node: save/RestoreV2_28/_69 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_251_save/RestoreV2_28", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]]

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Traceback (most recent call last):
File "./tools/train_net.py", line 86, in
imdb= get_imdb(args.roidb, args.imdb, args.rpndb, split=0)
File "/home/duan/anaconda2/envs/tf/z/scene-graph-TF-release-master/tools/../lib/datasets/factory.py", line 10, in get_imdb
return vg_hdf5('%s.h5'%roidb_name, '%s-dicts.json'%roidb_name, imdb_name, rpndb_name, split=split, num_im=num_im)
File "/home/duan/anaconda2/envs/tf/z/scene-graph-TF-release-master/tools/../lib/datasets/vg_hdf5.py", line 42, in init
self.im_sizes = np.vstack([self.im_h5['image_widths'][split_mask],
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "/home/duan/anaconda2/envs/tf/lib/python2.7/site-packages/h5py/_hl/dataset.py", line 535, in getitem
if args == (Ellipsis,) or args == tuple():

Demo on own video

Thank you for releasing this repo. Would it be possible to use this model to do a demo on my own video? If yes, what would the steps to do so be? Thanks,

Generating proposals.h5

Hello,

I'm trying to generate the proposals.h5 and am using this python script as mentioned in other issues:

https://github.com/rbgirshick/py-faster-rcnn/blob/master/tools/rpn_generate.py

I have been using the mini_proposals.h5 file as a template for creating the necessary datasets and I've needed to modify this rpn_generate.py script extensively to create this h5 file. There appear to be 5 datasets which need to be generated:

  • im_scales
  • im_to_roi_idx
  • num_rois
  • rpn_rois
  • rpn_scores

I guess my question is, are all these datasets really required? I'm kinda hoping that im_scales wouldn't be necessary and I don't think it's used.

Thanks.

Generating Scene Graphs for images not in VG

Hi @danfeiX ,
I really wanted to generate scene graphs for images, which are from some other dataset. I don't have ground truth scene graphs and I don't wish to evaluate the generation process, but to only obtain scene graph for some other research task.
Can you please guide me as to how to proceed with this?
Thanks in Advance!

Anyone know how to solve this bug?

InvalidArgumentError (see above for traceback): No OpKernel was registered to support Op 'RoiPoolGrad' with these attrs. Registered devices: [CPU], Registered kernels:
device='GPU'; T in [DT_FLOAT]

 [[Node: gradients/rel_pool5_grad/RoiPoolGrad = RoiPoolGrad[T=DT_FLOAT, pooled_height=7, pooled_width=7, spatial_scale=0.0625](conv_out, Placeholder_2, rel_pool5:1, gradients/rel_fc6/Reshape_grad/Reshape)]]

Ubuntu:16.04
Tensorflow-gpu=0.12

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.