validation/rfcn.py
def demo(net, image_name):
    """Detect object classes in an image using pre-computed object proposals."""

    # Load the demo image
    im_file = os.path.join(cfg.DATA_DIR, 'demo', image_name)
    im = cv2.imread(im_file)

    # Detect all object classes and regress object bounds
    timer = Timer()
    timer.tic()
    scores, boxes = im_detect(net, im)
    timer.toc()
    print ('Detection took {:.3f}s for {:d} object proposals'.format(timer.total_time, boxes.shape[0]))

#     # Output tracklet to label file
#     fileID = fopen(sprintf('%s/%06d.txt', output_dir, img_idx) ,'a');
#     # Object label
#     fprintf(fileID,'%s ',tracklets{it}.objectType);
   
#     # 2D boundingbox
#     fprintf(fileID,'%.2f ',box.x1);
#     fprintf(fileID,'%.2f ',box.y1);
#     fprintf(fileID,'%.2f ',box.x2);
#     fprintf(fileID,'%.2f ',box.y2);

   
    
    # Visualize detections for each class
    CONF_THRESH = 0.8
    NMS_THRESH = 0.3
    f = open("detections/"+str(image_name).split('.')[0]+".txt", "a")
    for cls_ind, cls in enumerate(CLASSES[1:]):
        #print(cls_ind)
        cls_ind += 1 # because we skipped background
        cls_boxes = boxes[:, 4:8]
        cls_scores = scores[:, cls_ind]
        if (cls_ind == 7):
            k=0
            for box in cls_boxes:
                f.write(str(CLASSES[7])+' ')
                f.write(str(scores[k,cls_ind])+' ')
                for i in range(0,len(box)):
                    f.write(str(box[i])) 
                    f.write(' ')
                f.write('\n')
                k = k+1
            f.close()
            #print(cls_boxes)
        #print(cls_scores)
        dets = np.hstack((cls_boxes,
                          cls_scores[:, np.newaxis])).astype(np.float32)
        keep = nms(dets, NMS_THRESH)
        dets = dets[keep, :]
        vis_detections(im, cls, dets, thresh=CONF_THRESH)
    plt.savefig("results/"+str(image_name))
Detect object classes in an image using pre-computed object proposals.
Detect object classes in an image using pre-computed object proposals.
Detect object classes in an image using pre - computed object proposals .
def demo(net, image_name):
    im_file = os.path.join(cfg.DATA_DIR, 'demo', image_name)
    im = cv2.imread(im_file)
    timer = Timer()
    timer.tic()
    scores, boxes = im_detect(net, im)
    timer.toc()
    print ('Detection took {:.3f}s for {:d} object proposals'.format(timer.total_time, boxes.shape[0]))
    CONF_THRESH = 0.8
    NMS_THRESH = 0.3
    f = open("detections/"+str(image_name).split('.')[0]+".txt", "a")
    for cls_ind, cls in enumerate(CLASSES[1:]):
        cls_ind += 1 
        cls_boxes = boxes[:, 4:8]
        cls_scores = scores[:, cls_ind]
        if (cls_ind == 7):
            k=0
            for box in cls_boxes:
                f.write(str(CLASSES[7])+' ')
                f.write(str(scores[k,cls_ind])+' ')
                for i in range(0,len(box)):
                    f.write(str(box[i])) 
                    f.write(' ')
                f.write('\n')
                k = k+1
            f.close()
        dets = np.hstack((cls_boxes,
                          cls_scores[:, np.newaxis])).astype(np.float32)
        keep = nms(dets, NMS_THRESH)
        dets = dets[keep, :]
        vis_detections(im, cls, dets, thresh=CONF_THRESH)
    plt.savefig("results/"+str(image_name))
def demo ( net , image_name ) : im_file = os . path . join ( cfg . DATA_DIR , 'demo' , image_name ) im = cv2 . imread ( im_file ) timer = Timer ( ) timer . tic ( ) scores , boxes = im_detect ( net , im ) timer . toc ( ) print ( 'Detection took {:.3f}s for {:d} object proposals' . format ( timer . total_time , boxes . shape [ 0 ] ) ) CONF_THRESH = 0.8 NMS_THRESH = 0.3 f = open ( "detections/" + str ( image_name ) . split ( '.' ) [ 0 ] + ".txt" , "a" ) for cls_ind , cls in enumerate ( CLASSES [ 1 : ] ) : cls_ind += 1 cls_boxes = boxes [ : , 4 : 8 ] cls_scores = scores [ : , cls_ind ] if ( cls_ind == 7 ) : k = 0 for box in cls_boxes : f . write ( str ( CLASSES [ 7 ] ) + ' ' ) f . write ( str ( scores [ k , cls_ind ] ) + ' ' ) for i in range ( 0 , len ( box ) ) : f . write ( str ( box [ i ] ) ) f . write ( ' ' ) f . write ( '\n' ) k = k + 1 f . close ( ) dets = np . hstack ( ( cls_boxes , cls_scores [ : , np . newaxis ] ) ) . astype ( np . float32 ) keep = nms ( dets , NMS_THRESH ) dets = dets [ keep , : ] vis_detections ( im , cls , dets , thresh = CONF_THRESH ) plt . savefig ( "results/" + str ( image_name ) )
Detect object classes in an image using pre-computed object proposals.
Detect object classes in an image using pre - computed object proposals .
"""Detect object classes in an image using pre-computed object proposals.""" # Load the demo image # Detect all object classes and regress object bounds #     # Output tracklet to label file #     fileID = fopen(sprintf('%s/%06d.txt', output_dir, img_idx) ,'a'); #     # Object label #     fprintf(fileID,'%s ',tracklets{it}.objectType); #     # 2D boundingbox #     fprintf(fileID,'%.2f ',box.x1); #     fprintf(fileID,'%.2f ',box.y1); #     fprintf(fileID,'%.2f ',box.x2); #     fprintf(fileID,'%.2f ',box.y2); # Visualize detections for each class #print(cls_ind) # because we skipped background #print(cls_boxes) #print(cls_scores)
net
image_name