Giter Site home page Giter Site logo

tf-faster-rcnn's Introduction

tf-Faster-RCNN

A Python 3/TensorFlow implementation of Faster R-CNN (paper). See official implementations here:

The deep models in this implementation are built on TensorBase, a minimalistic framework for end-to-end TensorFlow applications created by my good friend and collaborator Dan Salo. Check it out. My personal fork (whose changes are typically regularly pulled into Dan's) is a submodule of this tf-Faster-RCNN repo.

Contents

  1. Requirements: Software
  2. Installation
  3. Repo Organization
  4. Simple Demo
  5. Training and Testing Your Data

Requirements: Software

  1. Ubuntu 16: I haven't tested it on any other Linux distributions or versions, but there's a chance it might work as is. Let me know if it does!
  2. Python 3.5+: I recommend Anaconda for your Python distribution and package management. See (3) below.
  3. TensorFlow v1.0: See TensorFlow Installation with Anaconda. Install the version that matches your preferred Python version. Instructions for Python 3.6 below:
# Create a Conda environment for TensorFlow (defaults to Python 3.6)
conda create --name tensorflow 

# Activate your environment
source activate tensorflow

# Install TensorFlow, for Python 3.6 with GPU support
pip install --ignore-installed --upgrade \
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl
  1. Some additional python packages you may or may not already have: cython, easydict, matplotlib scipy, Pillow, pyyaml, tqdm. These should all be pip installable within your Anaconda environment (pip install [package]):
pip install cython easydict matplotlib scipy Pillow pyyaml tqdm 
  1. TensorBase: Tensorbase is used as a submodule, so you can get this recursively while cloning this repo. See Installation below.

Installation

  1. Clone this repository (tf-Faster-RCNN)
# Make sure to clone with --recursive. This'll also clone TensorBase
git clone --recursive https://github.com/kevinjliang/tf-Faster-RCNN.git
  1. We'll call the directory that you cloned tf-Faster-RCNN into tf-FRC_ROOT

    Ignore notes 1 and 2 if you followed step 1 above.

    Note 1: If you didn't clone tf-Faster-RCNN with the --recursive flag, then you'll need to manually clone the TensorBase submodule:

    git submodule update --init --recursive

    Note 2: The TensorBase submodule needs to be on the faster-rcnn branch (or equivalent detached state). This will happen automatically if you followed step 1 instructions.

  2. Build the Cython modules

cd $tf-FRC_ROOT/Lib
make

Repo Organization

  • Data: Scripts for creating, downloading, organizing datasets. Output detections are saved here. For your local copy, the actual data will also reside here
  • Development: Experimental code still in development
  • Lib: Library functions necessary to run Faster R-CNN
  • Logs: Holds the tfevents files for TensorBoard, model checkpoints for restoring, and validation/test logs. This directory is created the first time you run a model.
  • Models: Runnable files that create a Faster R-CNN class with a specific convolutional network and dataset. Config files for changing model parameters are also here.
  • Networks: Neural networks or components that form parts of a Faster R-CNN network

Simple Demo

If you would like to try training and/or testing the Faster R-CNN network, we currently have a complete model available for cluttered MNIST. Cluttered MNIST is a dataset of images consisting of randomly scaled MNIST digits embedded in a larger image, with random pieces of other MNIST digits scattered throughout. It serves as a simple dataset for detection, as the algorithm must find the digit and classify it. PASCAL VOC and MS COCO on the way.

To run the model on cluttered MNIST:

  1. Generate the data:
cd $tf-FRC_ROOT/Data/scripts

# Generate images and bounding box data; place it in the folder $tf-FRC_ROOT/Data/clutteredMNIST 
python MNIST.py
  1. Run the model:
cd $tf-FRC_ROOT/Models

# Change flags accordingly (see argparser in main() of Model/faster_rcnn_conv5.py file)
python faster_rcnn_conv5.py -n [Model num, ex 1] -e [Num of epochs, ex 5]
  1. To reload a previously trained model and test
# For just mAP and AP performance metrics:
python faster_rcnn_conv5.py -r 1 -m [Model num] -f [epoch to restore] -t 0

# To also save test images with overlaid detection boxes as PNGs:
python faster_rcnn_conv5.py -r 1 -m [Model num] -f [epoch to restore] -t 0 -i 1

Training and Testing Your Data

In order to train (and then test) on your own data:

Organize your data into the following format:

|--tf-FRC_ROOT
  |--Data/
    |--[YOUR_DATASET]/
      |--Annotations/
        |--*.txt (Annotation Files: (x1,y1,x2,y2,label))
      |--Images/
        |--*.[png/jpg] (Image files)
      |--Names/
        |--train.txt (List of training data filenames)
        |--valid.txt (List of validation data filenames)
        |--test.txt  (List of testing data filenames)

Step 1 of the cluttered MNIST demo automatically creates this data and organizes it accordingly, so run the MNIST.py script for an example file structure.

Optional: Pre-trained convolutional feature extractor weights

If you want to use pre-trained weights for the convolutional feature extractor (highly recommended), you have to download those here. Currently, we have ResNet 50 V1 available; to use it, download the appropriate checkpoint file first.

Configure the model

The network architecture and model parameters depend on the kind of data you are trying to process. Most of these are adjustable from the config file.

Default settings and their descriptions are located at Lib/faster_rcnn_config.py. You should not modify this. Instead, write a yaml file, save it under Models/cfgs, and pass it as an argument to your model. See Models/cfgs/ for examples.

In particular, make sure to change the following:

  • Point DATA_DIRECTORY to your dataset folder (denoted by [YOUR_DATASET] in the earlier file tree). Make this path relative to the Models/ directory.
  • Optional: Point RESTORE_SLIM_FILE to the location of the checkpoint file you downloaded, if using pre-trained weights for the convolutional feature extractor.
  • Change CLASSES to a list of the class names in your data. IMPORTANT: Leave the first class as 'background'
  • Update NUM_CLASSES to the number of classes in CLASSES

The model file you use depends on the data you wish to train on. For something like the simple, single-channeled cluttered MNIST, Model/faster_rcnn_conv5.py is probably sufficient. More complex, RGB-channeled real data like PASCAL VOC, MS COCO, or ImageNet require a correspondingly more advanced architecture (example).

Make sure that the number of channels of the input placeholder in the _data constructor function matches your data. faster_rcnn_conv5.py is defaulted to a single channel (grayscale). faster_rcnn_resnet50ish.py is three channels (RGB).

Train and Test

To train the model (assumingfaster_rcnn_resnet50ish.py):

python faster_rcnn_resnet50ish.py [arguments]

Additional arguments (defaults in parentheses; see main() of a model file for additional comments):

  • [-n]: Run number (0) - Log files and checkpoints will be saved under this ID number
  • [-e]: Epochs (1) - Number of epochs to train the model
  • [-r]: Restore (0) - Restore all weights from a specific run number ID (a previous -n) and checkpoint number if equal to 1. Additional specifications in -m and -f (see below)
  • [-m]: Model Restore (1) - Specifies which previous run number ID (a previous -n) to restore from
  • [-f]: File Epoch (1) - Specifies which epoch checkpoint to restore from
  • [-s]: Slim (1) - For models with pre-trained weights, load weights from a downloaded checkpoint if equal to 1
  • [-t]: Train (1) - Train the model if equal to 1 (Set this to 0 if you only want to evaluate)
  • [-v]: Eval (1) - Evaluate the model if equal to 1
  • [-y]: YAML (pascal_voc2007.yml) - Name of the YAML file in the Models/cfg/ folder to override faster_rcnn_config.py defaults
  • [-l]: Learning Rate (1e-3) - Initial Learning Rate (You should actually probably specify this in your YAML, not here)
  • [-i]: Visualize (0) - Project output bounding boxes onto your images and save under Data/[YOUR_DATASET]/Outputs if equal to 1
  • [-g]: GPU (0) - Specify which GPU to use. Input 'all' to use all available GPUs.

Common use cases:

# Train model, starting from pre-trained weights
python faster_rcnn_resnet50ish.py -n 10 -e 20 -y 'myYAML.yml'

# Test model, using a previously trained model (0). Save output images with boxes
python faster_rcnn_resnet50ish.py -n 11 -r 1 -m 10 -f 18 -t 0 -i 1 -y 'myYAML.yml'

tf-faster-rcnn's People

Contributors

dancsalo avatar kevinjliang 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

tf-faster-rcnn's Issues

ImportError: No module names 'Lib.nms.gpu_nms'

I started with your repo step-by-step and now i reached a point where I am literally lost.

I am working with Tensorflow in Python3.5
python3.5 faster_rcnn_conv5.py -n 1 -e 5 throws an error (ImportError - see headline)

I executed make and changed the python version inside the Makefile to python3 and python3.5, both without success.

What am I doing wrong?

I also use a conda environment.

Thanks in advance.

Extremely low mAP

@kevinjliang Following up on previous questions, I'm also wondering if there are any known issues with this repo. I've been running tf-Faster-RCNN to detect lunar craters on a dataset of size 570, with tens of positive detections per image.

The precision and recall values are close to zero across the board, with the mAP on the order of 0.01. Do you have any idea of why this might be the case, and if there are any settings I should adjust? Thank you!

Overflow Error

./Lib/bbox_transform.py:66: RuntimeWarning: overflow encountered in exp | 0/5000 [00:00<?, ?it/s]
pred_w = np.exp(dw) * widths[:, np.newaxis]
../Lib/bbox_transform.py:67: RuntimeWarning: overflow encountered in exp
pred_h = np.exp(dh) * heights[:, np.newaxis]
../Lib/bbox_transform.py:67: RuntimeWarning: overflow encountered in multiply | 311/5000 [00:00<00:13, 346.46it/s]
pred_h = np.exp(dh) * heights[:, np.newaxis]
../Lib/bbox_transform.py:66: RuntimeWarning: overflow encountered in multiply | 347/5000 [00:01<00:13, 348.99it/s]
pred_w = np.exp(dw) * widths[:, np.newaxis]

I followed the training steps, and when I run
python faster_rcnn_conv5.py -r 1 -m [Model num] -f [epoch to restore] -t 0 -i 1
I got the problem. I print the dw and dh values, they are +-500000, which does not seem to be correct.

AP of zero for all classes

Hi Kevin and Dan,

First of all, thanks for making this repo. It's the first implementation of Faster R-CNN for Tensorflow that looks really nice!

I am currently trying to get things to work on PASCAL VOC 2007. After black-listing the images you mentioned in #2, training seems to run OK, and the loss goes down fine. However, the AP for all classes in validation and test seems to come out as 0.0. As far as I can tell, my data is formatted correctly.

Do you have any guesses of what might be causing this?

Thanks,
Martin

Why the model trained in Demo has poor generalization?

I trained the model with data in mnist cluster in Demo for 5 epochs, and i used my own pictures to test the model(preprocessed already), but the result was quite bad. Even I adjusted a little in the test set would cause bad result. Results are below:
hand_wrt3

hand_wrt4

hand_wrt8

The problem about training my own dataset!

Hi,
Recently, I made a set of dataset(images, 3 channels). But when I trained them using this code, problem occurred.
"Restoring TF-Slim-Model
Unsuccessful TensorSliceReader constructor : Failed to find any matching files for ../Data/"
Besides, I didn't use the pre-trained model. Does anybody know what the problem is??

Test or Eval always predicts error

Hello! Test or Eval accuracy always is zero.I try "faster_rcnn_conv5.py" and "faster_rcnn_resnet50ish.py" always get the same error(accuracy is zero).I also git clone your newest file,but same result. I also see the demo.I hope you run your example MNIST demo again,to find Whether something is wrong .thanks!

ImportError: No module named tqdm

I'm trying to run the demo for MNIST. But when I try this command: python MNIST.py, it gets to an error like this:

ImportError: No module named tqdm

and when I try to install tgdm with pip install tgdm it says:
Could not find a version that satisfies the requirement tgdm (from versions: ) No matching distribution found for tgdm

It works fine when I try it with python3: python3 MNIST.py. How can I do this with python 2.7?

Bbox detection problem on Test set

Hi ,

I am using the 5-th layer model on my own DataSet .. but after some epochs ( 20 ) , I checked the test result , then for all the test set ( 90 images ) I had a same 'strange' result : No correct detection and only the whole image box appears as detected

http://hpics.li/5ab74fb

I am using a grayscale images.

Could you help to fix that problem.

Thank you

Mohammed

Hyperparameter Tuning for own Dataset

Hello, I am currently training on road scene images and struggle with the hyper-parameter tuning.

In faster_rcnn_config.py are many different hyper-parameters to modify. It would take months to test the influence of each parameter. Does anybody here have an idea which parameters are the ones with the largest influence or which parameters should be modified first in order to obtain good results for the mentioned data?

Any recommendations (how to find a good setup) would be helpful.
Thanks in advance.

ImportError: No module named TensorBase.tensorbase.base

I'm trying to perform faster-RCNN demo based on this page. When I try to run the model (MNIST) with the command :python faster_rcnn_conv5.py -n [Model num, ex 1] -e [Num of epochs, ex 5], it comes to an error like this:

File "faster_rcnn_conv5.py", line 16, in
from Lib.TensorBase.tensorbase.base import Model, Data
ImportError: No module named TensorBase.tensorbase.base

How can I add this module?
I have already generated the data.

ubuntu16.04
python 2.7
cuda 8

how to get the recall rate?

I have performed the faster rcnn on a dataset and gotten the average precision (AR) results as they can be seen at the end of testing. How can I get the recall rate with respect to each precision to draw a precision-recall curve like below?
untitled

No module named TensorBase.tensorbase.base

Error when I try to run the model (MNIST) with the command :
$python faster_rcnn_conv5.py -n [Model num, ex 1] -e [Num of epochs, ex 5]

Traceback (most recent call last):
File "faster_rcnn_conv5.py", line 16, in
from Lib.TensorBase.tensorbase.base import Model, Data
ImportError: No module named TensorBase.tensorbase.base

The problem of the NUM_CLASSES

In /lib/faster_rcnn_config.py,

# Classes: The types of objects the algorithm is trying to find
# First class must be __background__
__C.CLASSES = ['__background__']
__C.NUM_CLASSES = 1

Why is NUM_CLASSES not 21? Or this is write error?

InvalidArgumentError

After following all your instructions and checking that all my images contain valid bounding boxes, I faced the following error:
InvalidArgumentError (see above for traceback): ValueError: attempt to get argmax of an empty sequence
[[Node: model/rpn/target/PyFunc = PyFunc[Tin=[DT_FLOAT, DT_INT32, DT_INT32, DT_INT32, DT_INT32], Tout=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], token="pyfunc_0", _device="/job:localhost/replica:0/task:0/cpu:0"](model/rpn/cls/conv_1/Mul/_2579, _arg_Placeholder_2_0_2, _arg_Placeholder_1_0_1, model/rpn/target/PyFunc/input_3, model/rpn/target/PyFunc/input_4)]]
[[Node: losses/fast_rcnn_cls_loss/SparseSoftmaxCrossEntropyWithLogits/Shape/_2565 = _HostRecvclient_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_5640_losses/fast_rcnn_cls_loss/SparseSoftmaxCrossEntropyWithLogits/Shape", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/gpu:0"]]

Can you please help me resolve this issue?

ValueError: The `strides` argument must be a tuple of 2 integers

when I was training ,an error comes up:

Traceback (most recent call last):
File "/home/zz/code/tf-Faster-RCNN/Models/faster_rcnn_resnet50ish.py", line 300, in
main()
File "/home/zz/code/tf-Faster-RCNN/Models/faster_rcnn_resnet50ish.py", line 291, in main
model = FasterRcnnRes50(flags, dictionary)
File "/home/zz/code/tf-Faster-RCNN/Models/faster_rcnn_resnet50ish.py", line 44, in init
super().init(flags_input, flags_input['run_num'], vram=cfg.VRAM, restore=flags_input['restore_num'], restore_slim=flags_input['restore_slim_file'])
File "/home/zz/code/tf-Faster-RCNN/Lib/TensorBase/tensorbase/base.py", line 676, in init
self._network()
File "/home/zz/code/tf-Faster-RCNN/Models/faster_rcnn_resnet50ish.py", line 82, in _network
self._faster_rcnn(self.x['TRAIN'], self.gt_boxes['TRAIN'], self.im_dims['TRAIN'], 'TRAIN')
File "/home/zz/code/tf-Faster-RCNN/Models/faster_rcnn_resnet50ish.py", line 93, in _faster_rcnn
feature_maps = resnet50_reduced(x)
File "/home/zz/code/tf-Faster-RCNN/Networks/resnet50_reduced.py", line 81, in resnet50_reduced
net = resnet_utils.stack_blocks_dense(net, blocks, output_stride)
File "/home/zz/anaconda3/envs/tensorflow1.0/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 177, in func_with_args
return func(*args, **current_args)
File "/home/zz/anaconda3/envs/tensorflow1.0/lib/python3.6/site-packages/tensorflow/contrib/slim/python/slim/nets/resnet_utils.py", line 229, in stack_blocks_dense
rate=1)
File "/home/zz/anaconda3/envs/tensorflow1.0/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 177, in func_with_args
return func(*args, **current_args)
File "/home/zz/code/tf-Faster-RCNN/Networks/resnet50_reduced.py", line 30, in bottleneck
shortcut = slim.conv2d(inputs, depth, [1, 1], stride=stride, activation_fn=None, scope='shortcut')
File "/home/zz/anaconda3/envs/tensorflow1.0/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 177, in func_with_args
return func(*args, **current_args)
File "/home/zz/anaconda3/envs/tensorflow1.0/lib/python3.6/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 906, in convolution
_reuse=reuse)
File "/home/zz/anaconda3/envs/tensorflow1.0/lib/python3.6/site-packages/tensorflow/python/layers/convolutional.py", line 419, in init
name=name, **kwargs)
File "/home/zz/anaconda3/envs/tensorflow1.0/lib/python3.6/site-packages/tensorflow/python/layers/convolutional.py", line 105, in init
self.strides = utils.normalize_tuple(strides, rank, 'strides')
File "/home/zz/anaconda3/envs/tensorflow1.0/lib/python3.6/site-packages/tensorflow/python/layers/utils.py", line 84, in normalize_tuple
str(n) + ' integers. Received: ' + str(value))
ValueError: The strides argument must be a tuple of 2 integers. Received: stride

It seems that there is something wrong in the file "resnet_utils.py".
I thought the wrong sentence is in LINE207:
"unit_depth, unit_depth_bottleneck, unit_stride = unit"
That it can't doing that dict operation in Python ...
Has anyone meets this same problem?????

thx

Cannot train ResNet Model on my own DataSet

Hi ,
I'm trying to train my own DataSet of an RGB images with the Resnet model , using the script " faster_rcnn_resnet50ish.py " , however the error below occured and I couldn't fix it ..
"Restoring TF-Slim-Model
Unsuccessful TensorSliceReader constructor : Failed to find any matchinf files for ../Data
/"
Thank you

No images for PascalVOC

I tried to run faster_rcnn_conv5.py for PascalVOC and noticed that there are no images in a folder Images generated by PASCAL_VOC.py script.

gt_box of MNIST

I have some question about def create_gt_box of MNIST.py. since you have computed the groud truth bouding boxes and saved it, why predict the bouding box by Faster RCNN

TypeError: __init__() got an unexpected keyword argument 'vram'

Hi

i'm newbie in tensorflow
(thank you for this code it's very nice!)

i try this code

simple demo

cd $tf-FRC_ROOT/Models

Change flags accordingly (see argparser in main() of Model/faster_rcnn_conv5.py file)

python faster_rcnn_conv5.py -n [Model num, ex 1] -e [Num of epochs, ex 5]

and success it

but i can't success this code
python faster_rcnn_resnet50ish.py -n 10 -e 20 -y 'clutteredMNIST.yml'

it see this error:

Overriding default parameters with values from clutteredMNIST.yml file
Traceback (most recent call last):
File "faster_rcnn_resnet50ish.py", line 299, in
main()
File "faster_rcnn_resnet50ish.py", line 290, in main
model = FasterRcnnRes50(flags, dictionary)
File "faster_rcnn_resnet50ish.py", line 44, in init
super().init(flags_input, flags_input['run_num'], vram=cfg.VRAM, restore=flags_input['restore_num'], restore_slim=flags_input['restore_slim_file'])
TypeError: init() got an unexpected keyword argument 'vram'

how i can solve it?

thank you

Problem with Demo Model

Hello,

thank you very much for your work. I am also a very beginner to deep learning and programming with python and tensorflow (but i am not a beginner with programming) and cannot get your demo "faster_rcnn_conv5" to run log-file.txt. Since my resources are very restricted i can only use CPUs.

--> So my first question is, whether it is possible to get your demo code runnuing with only CPUs? I do not need training; testing would be enough so that i can try to understand the mechanisms in Faster RCNN together with tensorflow.

Using your actual repository and executing the code results in an error regarding 'vram'. I checked out an older commit to resolve this problem (using your answer in another issue) but then experienced another problem.

--> My second question: Would it be possible for you to reupload a full functional demo using neither cpu or gpu? It would be very helpful for newcomers like me, since tensorflow is more and more getting powerful with tensorflow-slim and since Faster R-CNN is a wonderful algorithm :) It would clearly help my scientific work (i am doing a master thesis right now).

Thank you!

Regards
Nam

InvalidArgumentError (see above for traceback): assertion failed: [] [Condition x == y did not hold element-wise:] [x (losses/fast_rcnn_cls_loss/SparseSoftmaxCrossEntropyWithLogits/Shape_1:0) = ] [101 1] [y (losses/fast_rcnn_cls_loss/SparseSoftmaxCrossEntropyWithLogits/strided_slice:0) = ] [101]

Hi,
I'm trying to train clutteredMNIST of gray images with ResNet 50 V1 model, using the command "python faster_rcnn_conv5.py -n 10 -e 20 -y 'clutteredMNIST.yml' ",however the error below occured
"InvalidArgumentError (see above for traceback): assertion failed: [] [Condition x == y did not hold element-wise:] [x (losses/fast_rcnn_cls_loss/SparseSoftmaxCrossEntropyWithLogits/Shape_1:0) = ] [101 1] [y (losses/fast_rcnn_cls_loss/SparseSoftmaxCrossEntropyWithLogits/strided_slice:0) = ] [101]"

Average Precision for class error

Hello! I run your mnist exmaple.During training ,Average Precision always is zero?(I always follow your step)
Detecting images in VALID set
100%|██████████████████████████████████████| 5000/5000 [00:19<00:00, 254.80it/s]No detections were made
Average Precision for class 1: 0.0
Average Precision for class 2: 0.0
Average Precision for class 3: 0.0
Average Precision for class 4: 0.0
Average Precision for class 5: 0.0
Average Precision for class 6: 0.0
Average Precision for class 7: 0.0
Average Precision for class 8: 0.0
Average Precision for class 9: 0.0
Average Precision for class 0: 0.0
Mean Average Precision on VALID Set: 0.000000

Shape problem

I prepaired PascalVOC dataset and ran

python faster_rcnn_conv5.py -n 1 -e 50 -y pascal_voc2007.yml

It shows a lot of info including following

Using GPU 0
conv_1 output: (1, ?, ?, 32)
conv_2 output: (1, ?, ?, 64)
...
fc_1 output: (?, 1024)
fc_2 output: (?, 1024)
fc_1 output: (?, 21)
fc_1 output: (?, 84)
/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/gradients_impl.py:93: 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. "

At the end I've got an error

Traceback (most recent call last):                                                                         | 0/5011 [00:00<?, ?it/s]
  File "faster_rcnn_conv5.py", line 286, in <module>
    main()
  File "faster_rcnn_conv5.py", line 279, in main
    model.train()
  File "faster_rcnn_conv5.py", line 159, in train
    summary = self._run_train_iter(feed_dict)
  File "faster_rcnn_conv5.py", line 127, in _run_train_iter
    summary, _ = self.sess.run([self.merged, self.optimizer], feed_dict=feed_dict)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 786, in run
    run_metadata_ptr)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 972, in _run
    % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (1, 375, 500, 3) for Tensor 'Placeholder:0', which has shape '(1, ?, ?, 1)'

Thank you for solving issue #3, but I can fix issues myself if you explain me how it works in your environment and how do you expect it working in the future.

Low mAP on Pascal VOC2007 dataset.

I followed the instruction and trained a model based on pre-trained resnet50 v1 model with Pascal VOC2007 dataset. But the mAP was always stuck at 30 or so. Has anyone tried this dataset yet? Any help will be greatly appreciated!

deprecated API in class roi_proposal()?

roi_proposal_net = roi_proposal(rpn_net, gt_boxes, im_dims, eval_mode, flags)

roi_proposal_net = roi_proposal(rpn_net, gt_boxes, im_dims, eval_mode)

It seems like you have changed these functions. Would you be willing to share the update?
from Networks.faster_rcnn_networks import rpn, roi_proposal, fast_rcnn

Does this version work now? or is this depreciated?

INFO:root:Average Precision for class 1: 0.0
INFO:root:Average Precision for class 2: 0.0
INFO:root:Average Precision for class 3: 0.0
INFO:root:Average Precision for class 4: 0.0
INFO:root:Average Precision for class 5: 0.0
INFO:root:Average Precision for class 6: 0.0
INFO:root:Average Precision for class 7: 0.0
INFO:root:Average Precision for class 8: 0.0
INFO:root:Average Precision for class 9: 0.0
INFO:root:Average Precision for class 0: 0.0
INFO:root:Mean Average Precision on VALID Set: 0.000000 -- this is what i got after every epoch..

CPU mode

Hi Kevin, I do not own a GPU. Would you advise if I could run the code in CPU mode? Thanks.

Segmentation Fault(OOM)

The first time when I use pre-trained resnet50 with my own data, it did work for 5 images then OOM Error occurred.
The second time when I tried to reduce the BATCH_SIZE from 128 to 64, there came the Segmentation Fault.
And I copy the code to another pc, it came the 'no module named TensorBase.tensorbase.base'.
I almost get crazy and is there any help? Thanks

No detections were made! Average precision and mean precision is Zero!!

Hi,
I used this set of codes to detect my own dataset, but got bad results. I don't know why. My dataset has only one class, and 300 imges in train dataset, 63 images in test dataset, 61 images in validation dataset, because I just wanna test this code first.
Some changes I made are: mini_batch size is 10, epoch is 5, pre-trained weights is downloaded, new yml file is also written, FRCNN_FC_HIDDEN has changed to [1024,1024].
Is my trained model overfitted?? Or is there something wrong in my changes??
sss
here is the result.

ValueError: operands could not be broadcast together with shapes

I'm trying to run python MNIST.py with python 2.7, but I get this error:

File "MNIST.py", line 139, in gen_nCluttered

embedded[y:y + h, x:x + w] += digit ValueError: operands could not be broadcast together with shapes (23,26) (0,0) (23,26)

It does work with python 3.5. How can I make it work it with python 2?

This is the part which has the error:

%# Insert digit into blank full size image and get max
embedded = np.zeros([im_dims[0], im_dims[1]])
embedded[y:y + h, x:x + w] += digit
max_val = max(embedded.max(), max_val)

Is this ROI-pooling approach reasonable

I noticed that there are many differences between the original author's method of ori-pooling with tensorflow's tf. image. crop_and_resize directly in your code. Is this method reasonable?

The question about roi pooling?

In the file Lib/roi_pool.py, the boxes don't multiply spatial_scale, but the boxes is within the scope of the input image, but we need to get the feature of the roi region, do we need to multiply spatial_scale with the "boxes"?

please help me to for how to get the high accuracy in faster-rcnn and parameter tuning

For getting more accuracy in faster-rcnn , which parameters i have to tune (tuning parameters). please anybody provide the solution for that problem, actually my model is working but the problem is getting less accuracy and some miss classifications are happens , so please kindly provide solution for getting high accuracy in the model.

Thanking you!

Does feature map should be expand to rank 4?

In roi_pool.py, line 38,

pooledFeatures = tf.image.crop_and_resize(image=featureMaps, boxes=boxes, box_ind=box_ind, crop_size=crop_size)

Just as I know, the featureMaps should be [batch,width,height,channels],Although batch is one,but it shouldn't be ignored. After your convnet the featureMap size is [width,height,channels] and I don't find tf.expand_dims to modify the featureMaps. I wonder to know whether it is correct?

Thank you for your help, I am a little anxious about this problems.

Your library is excellent and I really love it, it helps me learn faster-rcnn clearly.

ImportError: ../Lib/nms/gpu_nms.so: undefined symbol: _Py_ZeroStruct

Hi
I'm trying to perform faster-RCNN demo based on this page. When I try to run a sample model with python 3, it comes to errors like this:

ImportError: ../Lib/nms/gpu_nms.so: undefined symbol: _Py_ZeroStruct

I tried to comment this line:
from .nms.gpu_nms import gpu_nms
in nms_wrapprt.py and the error became like this:

ImportError: ../Lib/nms/cpu_nms.so: undefined symbol: _Py_ZeroStruct

Now when I comment this line also:
nms.cpu_nms import cpu_nms

the error changes to this:

ImportError: ../Lib/bbox_overlaps.so: undefined symbol: _Py_ZeroStruct

What can I do to make this .so files to work with python 3?

(Ubuntu 16.04
cuda 8.0
pyhton 2.7 and 3.5)

Problem of Line 44 in file 'tf-Faster-RCNN/Models/faster_rcnn_resnet50ish.py'

Line 44 in file 'tf-Faster-RCNN/Models/faster_rcnn_resnet50ish.py':

super().init(flags_input, flags_input['run_num'], vram=cfg.VRAM, restore=flags_input['restore_num'], restore_slim=flags_input['restore_slim_file'])

This line calls the Model's init function, however, which I found only received two arguments: flags and config_dict.
So this line can run correctly?

Since I use python2, so I cannot test it. I just want to rewrite this project to python2 and I am curious about this line.

So please give me some help. Thank you.

bottleneck() arguments

I configured frcnn in docker. But when I start training faster_rcnn_resnet50ish.py I've got the following error:

Traceback (most recent call last):
  File "faster_rcnn_resnet50ish.py", line 300, in <module>
    main()
  File "faster_rcnn_resnet50ish.py", line 291, in main
    model = FasterRcnnRes50(flags, dictionary)
  File "faster_rcnn_resnet50ish.py", line 44, in __init__
    super().__init__(flags_input, flags_input['run_num'], vram=0.8, restore=flags_input['restore_num'], restore_slim=flags_input['restore_slim_file'])
  File "../Lib/TensorBase/tensorbase/base.py", line 722, in __init__
    self._network()
  File "faster_rcnn_resnet50ish.py", line 83, in _network
    self._faster_rcnn(self.x['TRAIN'], self.gt_boxes['TRAIN'], self.im_dims['TRAIN'], 'TRAIN')
  File "faster_rcnn_resnet50ish.py", line 94, in _faster_rcnn
    res_features = resnet50_reduced(x, is_training=False, output_stride=16)
  File "../Networks/resnet50_reduced.py", line 62, in resnet50_reduced
    net = resnet_utils.stack_blocks_dense(net, blocks, output_stride)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 181, in func_with_args
    return func(*args, **current_args)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/slim/python/slim/nets/resnet_utils.py", line 216, in stack_blocks_dense
    net = block.unit_fn(net, rate=1, **unit)
TypeError: bottleneck() argument after ** must be a mapping, not tuple

As far as I understand unit_fn is the internal name for bottlenek routine provided for Block construction. So, it should actually take mapping (dict) of arguments to those values. Also I printed the unit variable before the following line net = block.unit_fn(net, rate=1, **unit) and unit is the tuple (256, 64, 1).
But I read the Block class description and I saw examples of resnet_utils.stack_blocks_dense routine call and I understand that Block constrcution like this resnet_utils.Block('block1', bottleneck, [(256, 64, 1)] * 2 + [(256, 64, 2)]) is correct.

What is the problem? And how can I solve it? Is there anyone who ran this script successfully?

PS: I forgot to say that I changed the output_stride value for 16 instead of None. Because it fails the script running.
UPD: last line of the error message log provided.

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.