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

how detect multiple object on same image #594

Closed
janaka1984 opened this issue May 26, 2017 · 8 comments
Closed

how detect multiple object on same image #594

janaka1984 opened this issue May 26, 2017 · 8 comments

Comments

@janaka1984
Copy link

hi,

I have used following example https://huangying-zhan.github.io/2016/09/22/detection-faster-rcnn.html#Training%20on%20new%20dataset.

it can detect basketball, but I need to detect person also.
To do that I used person dataset with basketball dataset and changed train.txt and classes in basketball.py file

but it can not detect both object at once

what i need to change ?

thanks

@sulth
Copy link

sulth commented Oct 6, 2017

Have you got solution for multiple object detection within 1 frame.Please share me the tips.

@janaka1984
Copy link
Author

janaka1984 commented Oct 7, 2017

hi sulth,

call following block of code on main()

im = im[:, :, (2, 1, 0)]
fig, ax = plt.subplots(figsize=(12, 12))
 ax.imshow(im, aspect='equal')


for cls_ind, cls in enumerate(CLASSES[1:]):
        cls_ind += 1 # because we skipped background
        cls_boxes = boxes[:, 4*cls_ind:4*(cls_ind + 1)]
        cls_scores = scores[:, cls_ind]
        dets = np.hstack((cls_boxes,cls_scores[:, np.newaxis])).astype(np.float32)
        keep = nms(dets, NMS_THRESH)
        dets =  dets[keep, :]
        vis_detections(ax, cls, dets,  thresh=CONF_THRESH)
def vis_detections(ax, class_name , dets, thresh=0.5):    
"""Draw detected bounding boxes."""
    inds = np.where(dets[:, -1] >= thresh)[0]
    print(inds)

    if len(inds) == 0:
          return
    for i in inds:
        bbox = dets[i, :4]
        score = dets[i, -1]
        print(bbox[0],bbox[1],bbox[2],bbox[3])
        ax.add_patch(
                     plt.Rectangle((bbox[0], bbox[1]),
                     bbox[2] - bbox[0],
                     bbox[3] - bbox[1], fill=False,
                     edgecolor='red', linewidth=3.5)
        )
        ax.text(bbox[0], bbox[1] - 2,
                '{:s} {:.3f}'.format(class_name, score),
                bbox=dict(facecolor='blue', alpha=0.5),
                fontsize=14, color='white')

    ax.set_title(('{} detections with '
                  'p({} | box) >= {:.1f}').format(class_name, class_name,  thresh), fontsize=14)
    plt.draw()

i hope you will get out put as you expect, try it :)

@sulth
Copy link

sulth commented Oct 9, 2017

Yes.I got it.Thanks alot:)

@aakarshmalhotra
Copy link

Hi @janaka1984

I can see that you have followed the blog:
https://huangying-zhan.github.io/2016/09/22/detection-faster-rcnn.html#Training%20on%20new%20dataset

I am trying to reproduce the same results, however, I can't find the codes for basketball.py, basketball_eval.py and any other files for using this dataset. However, I have downloaded the dataset. Can you please guide me through this.

Thanks in advance.

@Niladri365
Copy link

I am looking for basketball.py and basketball_eval.py code. The annotations are also in .xml format instead of .txt format as INRIA person dataset. Would some body guide me in this regard?

@aakarshmalhotra
Copy link

@Niladri365
Copy link

Thanks a lot...

@Ram-Godavarthi
Copy link

@janaka1984 @sulth Can you share me the demo code where changes needs to done for getting 2 objects detection on single frame?. I tried your @janaka1984 solution. but i did not get it..
Could you please help me out..

Thank You

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

No branches or pull requests

5 participants