Exemple #1
0
        with tf.Session(config=config) as sess:

            init_op = tf.global_variables_initializer()
            model = sess.run(init_op)
            if os.path.isfile(os.getcwd() + "/" + cfg.weights_dir + "/checkpoint"):
                saver.restore(sess, model_file)
                print("Restored model")
            yolo.set_training(False)

            anchors = np.reshape(np.array(cfg.anchors), [-1, 2])
            images = load_file(sys.argv[1:])

            #normalise data  between 0 and 1
            imgs = (np.array([row[0] for row in images])/255)

            boxes = sess.run(yolo.output, feed_dict={
                yolo.x: imgs,
                yolo.anchors: anchors,
            })

            proc_boxes = yolo.convert_net_to_bb(boxes, filter_top=True)


            for box in proc_boxes:
                cls = yolo.names[int(box[0])]

                hex = cls.encode('utf-8').hex()[0:6]

                color = tuple(int(hex[k:k+2], 16) for k in (0, 2 ,4))

                print(cls, box[1], box[2], box[3], box[4], box[5])
                    if len(v_labels) == 0:
                        continue

                    res, correct, iou = sess.run(
                        [yolo.output, yolo.matches, yolo.best_iou],
                        feed_dict={
                            yolo.train_bounding_boxes: v_labels,
                            yolo.train_object_recognition: v_obj_detection,
                            yolo.x: v_imgs,
                            yolo.anchors: anchors,
                            yolo.iou_threshold: iou_threshold,
                            yolo.object_detection_threshold:
                            confidence_threshold
                        })

                    labels = yolo.convert_net_to_bb(res, filter_top=True)[0]

                    #v_obj_detection = np.zeros_like(v_obj_detection)

                    o_img, o_h, o_w, = res.shape[:3]

                    img = o_img - 1

                    if one_class:
                        v_obj_detection = np.zeros_like(v_obj_detection)

                    while img >= 0:
                        h = o_h - 1
                        while h >= 0:
                            w = o_w - 1
                            while w >= 0: