Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when i was training my data,there is a issue exist as follow:> d:\orgin\faster-rcnn-tensorflow-python3.5-master\faster-rcnn-tensorflow-python3.5-master\lib\layer_utils\proposal_target_layer.py(139)_sample_rois() -> keep_inds = np.append(fg_inds, bg_inds) (Pdb) #31

Closed
tdf1995 opened this issue May 14, 2018 · 31 comments

Comments

@tdf1995
Copy link

tdf1995 commented May 14, 2018

This problem appears after completing several rounds of training

@xupinjie
Copy link

i met the same problem.
did you solve it?

@tdf1995
Copy link
Author

tdf1995 commented May 17, 2018

@Jasonxu033 there is a problem in my dataset

@xupinjie
Copy link

@tdf1995 what problem?

@niuniu111
Copy link

I met the same problem. keep_inds = np.append(fg_inds, bg_inds) (Pdb), did you solve it?

@xupinjie
Copy link

@niuniu111 Some probles in your dateset. There are some pictures couldnot fit the annotation.

@niuniu111
Copy link

I use VGG16 to run normally. When running RESNET, there is a similar error. Does this mean that the data is OK?

@xupinjie
Copy link

@niuniu111 sorry i didn't try resnet

@lccate
Copy link

lccate commented May 23, 2018

I changed the learning rate from 0.0001 to 0.1,then the (Pdb) error occurs, I hope it will help you

@LarryJiang134
Copy link

LarryJiang134 commented Jul 13, 2018

For me, this error occurs randomly. I have trained entire pascal voc before yet the second day when I tried to train the network, I saw this error message. I don't think it is code which is problematic. This might because my GPU or RAM are not stable. Try to run it on another device.
Just my observation. Hope it is helpful.

@niuniu111
Copy link

It's hopeful,Thanks

@kmust-why
Copy link

imdb.append_flipped_images() Will this code affect?

@yhs95
Copy link

yhs95 commented Aug 15, 2018

f:\pycode\faster-rcnn-tensorflow-python3.5-master\lib\layer_utils\proposal_tar
get_layer.py(138)_sample_rois()
-> keep_inds = np.append(fg_inds, bg_inds)
(Pdb)

@kmust-why
Copy link

Is training your own data set?

@kmust-why
Copy link

You can try to reduce the value of SCALES.

@yhs95
Copy link

yhs95 commented Aug 15, 2018

I tried it, is it modified in config.py? How much is it appropriate to change the value of SCALES?

@kmust-why
Copy link

I use SCALES = [1,2,4,8,16], RATIOS = [0.5,1,2], you can try it.

@yhs95
Copy link

yhs95 commented Aug 15, 2018

The picture I used for training is a grayscale image.According to what you said, using SCALES = [1,2,4,8,16], RATIOS = [0.5,1,2] will not work.As shown.After entering c, this result appears
InvalidArgumentError (see above for traceback): Incompatible shapes: [0,24] vs.
[256,24]。

@kmust-why
Copy link

Have you solved this problem later? I have encountered this problem again today.

@Tju-AI
Copy link

Tju-AI commented Oct 8, 2018

This problem appears after completing several rounds of training

same question,have you solved it??

@niuniu111
Copy link

The picture I used for training is a grayscale image.According to what you said, using SCALES = [1,2,4,8,16], RATIOS = [0.5,1,2] will not work.As shown.After entering c, this result appears
InvalidArgumentError (see above for traceback): Incompatible shapes: [0,24] vs.
[256,24]。

same question, have you solved this problem? What is the reason?

@niuniu111
Copy link

Some probles in your dateset. There are some pictures couldnot fit the annotation.

I also meet the question,I want to know what mean "there are some pictures could not fit the annotation."can you answer the question specifically?

@morpheusthewhite
Copy link
Collaborator

Same question

@morpheusthewhite
Copy link
Collaborator

morpheusthewhite commented Feb 10, 2019

It seems to be caused by the following lines

    if fg_inds.size > 0 and bg_inds.size > 0:
        fg_rois_per_image = min(fg_rois_per_image, fg_inds.size)
        fg_inds = npr.choice(fg_inds, size=int(fg_rois_per_image), replace=False)
        bg_rois_per_image = rois_per_image - fg_rois_per_image
        to_replace = bg_inds.size < bg_rois_per_image
        bg_inds = npr.choice(bg_inds, size=int(bg_rois_per_image), replace=to_replace)
    elif fg_inds.size > 0:
        to_replace = fg_inds.size < rois_per_image
        fg_inds = npr.choice(fg_inds, size=int(rois_per_image), replace=to_replace)
        fg_rois_per_image = rois_per_image
    elif bg_inds.size > 0:
        to_replace = bg_inds.size < rois_per_image
        bg_inds = npr.choice(bg_inds, size=int(rois_per_image), replace=to_replace)
        fg_rois_per_image = 0
    else:
        import pdb
        pdb.set_trace()  # <----- this command launches python debugger and so it stops execution

    # The indices that we're selecting (both fg and bg)
    keep_inds = np.append(fg_inds, bg_inds)

Even if the error refers to the append the stop is caused by pdb.set_trace(). That line of code was put there probably to debug some unwanted situation regarding overlapping buonding boxes

@morpheusthewhite
Copy link
Collaborator

I solved by raising an exception instead of opening pdb

(in lib/layer_util/proposal_target_layer.py)

    if fg_inds.size > 0 and bg_inds.size > 0:
        fg_rois_per_image = min(fg_rois_per_image, fg_inds.size)
        fg_inds = npr.choice(fg_inds, size=int(fg_rois_per_image), replace=False)
        bg_rois_per_image = rois_per_image - fg_rois_per_image
        to_replace = bg_inds.size < bg_rois_per_image
        bg_inds = npr.choice(bg_inds, size=int(bg_rois_per_image), replace=to_replace)
    elif fg_inds.size > 0:
        to_replace = fg_inds.size < rois_per_image
        fg_inds = npr.choice(fg_inds, size=int(rois_per_image), replace=to_replace)
        fg_rois_per_image = rois_per_image
    elif bg_inds.size > 0:
        to_replace = bg_inds.size < rois_per_image
        bg_inds = npr.choice(bg_inds, size=int(rois_per_image), replace=to_replace)
        fg_rois_per_image = 0
    else:
        raise Exception()

and catching it in train.py

     # Compute the graph with summary
     try:
           rpn_loss_cls, rpn_loss_box, loss_cls, loss_box, total_loss = self.net.train_step(sess, blobs, train_op)
     except Exception:
           print('image invalid, skipping')
           continue

@Monti03
Copy link

Monti03 commented Feb 12, 2019

if you are using pascal_voc.py to deal with your dataset, you can try to remove -1 from _load_pascal_annotation in those rows:
x1 = float(bbox.find('xmin').text) - 1
y1 = float(bbox.find('ymin').text) - 1
x2 = float(bbox.find('xmax').text) - 1
y2 = float(bbox.find('ymax').text) - 1

@niuniu111
Copy link

when I use your approach, an exception is rainsing,which is proved image is wrong?@morpheusthewhite

@morpheusthewhite
Copy link
Collaborator

@niuniu111 yes, it is raised every time something in your dataset is not correct.
I met that problem when the annotation was associated to the wrong image; you should check it out

@gwspotex
Copy link

that's mean your fg & bg all return 0..
step1:
u can print the fg & bg then u can find it in dataset
step2:
if the dataset is OK u probably change RPN to small anchor & ratio
step3:
u can e-Maill to me :gwspotex@gmail.coM

@gwspotex
Copy link

that's mean your fg & bg all return 0..
step1:
u can print the fg & bg then u can find it in dataset
step2:
if the dataset is OK u probably change RPN to small anchor & ratio
step3:
u can e-Maill to me :gwspotex@gmail.com

@PangJian123
Copy link

i solve it.
First,find two lines in config.py:
tf.app.flags.DEFINE_float('roi_bg_threshold_high', 0.5, "Overlap threshold for a ROI to be considered background (class = 0 if overlap in [LO, HI))")
tf.app.flags.DEFINE_float('roi_bg_threshold_low', 0.1, "Overlap threshold for a ROI to be considered background (class = 0 if overlap in [LO, HI))")
Second,I modify two values :0.5 changed to 0.3 and 0.1 changed to 0.0.
I hope it can help you.

@dBeker
Copy link
Owner

dBeker commented Apr 2, 2019

@morpheusthewhite can you send your changes as PR?

morpheusthewhite added a commit to morpheusthewhite/Faster-RCNN-TensorFlow-Python3.5 that referenced this issue Apr 2, 2019
Pdb start is replaced by the raise of an exception catched in the main
loop
@dBeker dBeker closed this as completed in 6462763 Apr 3, 2019
dBeker pushed a commit that referenced this issue Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.