コード例 #1
0
	def __init__(self, line, sline1, sline2):
		#line is for counting
		#slines for speed estimation
		self.deepsort=deepsort_rbc()
		self.yolov3 = YOLOV3("cfg/yolo_2k_reanchored.cfg","weights/yolo_2k_reanchored_70000.weights","cfg/2k_aug.data")

		#New yolov3 model
		#self.yolov3 = YOLOV3("cfg/yolov3_rbc.cfg","weights/yolov3_rbc_60000.weights","cfg/2k_aug.data")		


		self.below_line=set()
		self.above_line=set()
		self.considered=set()
		self.speed1=set()
		self.idtocoords=dict()
		
		self.classes = ['car','bus','two-wheeler','three-wheeler','people','lcv','bicycle','truck']
		self.v_count_up= defaultdict(int)
		self.v_count_down= defaultdict(int)

		#Initialize each value to zero
		for c in self.classes:
			self.v_count_up[c]
			self.v_count_down[c]	

		self.sline1=sline1
		self.sline2=sline2
		self.line=line
		self.tot_dist=0
		self.tot_time=0
		self.speed=0
		self.speed_dict = defaultdict(int)
		self.frame_count = defaultdict(int)
コード例 #2
0
def freeze_graph(checkpoint_path, output_node_names, savename):
    with tf.name_scope('input'):
        input_data = tf.placeholder(dtype=tf.float32,
                                    shape=(1, INPUTSIZE, INPUTSIZE, 3),
                                    name='input_data')
        training = tf.placeholder(dtype=tf.bool, name='training')
    prefixdict = collectpth(checkpoint_path)
    output = YOLOV3(training).build_network_dynamic(input_data,
                                                    prefixdict,
                                                    inputsize=INPUTSIZE)
    with tf.Session() as sess:
        output_graph_def = tf.graph_util.convert_variables_to_constants(
            sess=sess,
            input_graph_def=sess.graph_def,
            output_node_names=output_node_names.split(","))
        with tf.gfile.GFile(savename, "wb") as f:
            f.write(output_graph_def.SerializeToString())
        print("%d ops in the final graph." % len(output_graph_def.node))
コード例 #3
0
    def __init__(self, line, sline1, sline2):
        #line is for counting
        #slines for speed estimation
        self.deepsort = deepsort_rbc()
        self.yolov3 = YOLOV3(
            "/home/shantam/alexDarknet/darknet/weights_2903/yolov3_rbc.cfg",
            "/home/shantam/alexDarknet/darknet/weights_2903/weights2/yolov3_rbc_180000.weights",
            "/home/shantam/alexDarknet/darknet/weights_2903/ta.data")

        #New yolov3 model
        #self.yolov3 = YOLOV3("cfg/yolov3_rbc.cfg","weights/yolov3_rbc_60000.weights","cfg/2k_aug.data")

        #self.below_line=set()
        #self.above_line=set()
        #self.considered=set()
        #self.speed1=set()
        #self.idtocoords=dict()

        self.classes = [
            'car', 'bus', 'two-wheeler', 'three-wheeler', 'people', 'lcv',
            'bicycle', 'truck'
        ]
コード例 #4
0
                        default='streams.txt',
                        help='source')
    parser.add_argument(
        "-fi",
        "--face_identified",
        help=
        "Tipo do identificador de faces utilizado: yolov3, mtcnn,mtcnno,retina",
        type=str,
        default='yolov3')
    args = parser.parse_args()

    conf = get_config(False)

    mtcnn = MTCNN()
    print('mtcnn loaded')
    yolov3 = YOLOV3()
    print("Yolov3 loaded")
    mtcnno = MTCNN_O()
    print("mtcnno loaded")
    retinanet = RETINANET("mobile0.25")
    print("retinanet loaded")

    learner = face_learner(conf, True)
    learner.threshold = args.threshold
    if conf.device.type == 'cpu':
        learner.load_state(conf, 'cpu_final.pth', True, True)
    else:
        learner.load_state(conf, 'mobilefacenet.pth', True, True)
    learner.model.eval()
    print('learner loaded')
コード例 #5
0
    heatmap_output, offset_output, wh_output = net(
        torch.autograd.Variable(torch.randn(3, 3, image_h, image_w)))
    annotations = torch.FloatTensor([[[113, 120, 183, 255, 5],
                                      [13, 45, 175, 210, 2]],
                                     [[11, 18, 223, 225, 1],
                                      [-1, -1, -1, -1, -1]],
                                     [[-1, -1, -1, -1, -1],
                                      [-1, -1, -1, -1, -1]]])
    decode = CenterNetDecoder(image_w, image_h)
    batch_scores3, batch_classes3, batch_pred_bboxes3 = decode(
        heatmap_output, offset_output, wh_output)
    print("3333", batch_scores3.shape, batch_classes3.shape,
          batch_pred_bboxes3.shape)

    from yolov3 import YOLOV3
    net = YOLOV3(backbone_type="darknet53")
    image_h, image_w = 416, 416
    obj_heads, reg_heads, cls_heads, batch_anchors = net(
        torch.autograd.Variable(torch.randn(3, 3, image_h, image_w)))
    annotations = torch.FloatTensor([[[113, 120, 183, 255, 5],
                                      [13, 45, 175, 210, 2]],
                                     [[11, 18, 223, 225, 1],
                                      [-1, -1, -1, -1, -1]],
                                     [[-1, -1, -1, -1, -1],
                                      [-1, -1, -1, -1, -1]]])
    decode = YOLOV3Decoder(image_w, image_h)
    batch_scores4, batch_classes4, batch_pred_bboxes4 = decode(
        obj_heads, reg_heads, cls_heads, batch_anchors)
    print("4444", batch_scores4.shape, batch_classes4.shape,
          batch_pred_bboxes4.shape)
コード例 #6
0

# def load_model(cfg_path,weights_path,data_path):
# net = load_net(cfg_path,weights_path, 0)
# meta = load_meta(data_path)

if __name__ == '__main__':
    mp.set_start_method('spawn')
    # establish queues
    m = mp.Manager()
    lock = m.Lock()
    tasks = mp.JoinableQueue()
    results = mp.Queue()
    filepath = sys.argv[1]

    yv3 = YOLOV3("cfg/yolo_2k_reanchored.cfg",
                 "weights/yolo_2k_reanchored_70000.weights", "cfg/2k_aug.data")
    # fchkr = folder_checker()
    #start consumers
    # number_consumers = mp.cpu_count() * 2
    number_consumers = 2
    print("cpu count = {}".format(number_consumers))

    consumers = [yolo_load(tasks, results) for i in range(number_consumers)]
    # print(consumers)
    for w in consumers:
        # print(w)
        w.start()

    streams = glob.glob(os.path.join(filepath, '*'))

    for strm in streams: