obendidi / Tracking-with-darkflow

Real-time people Multitracker using YOLO v2 and deep_sort with tensorflow
GNU General Public License v3.0
524 stars 176 forks source link

Getting error when trying to run mulitple videos from folder #14

Closed sathishmanivannan closed 6 years ago

sathishmanivannan commented 6 years ago

Run.py

from darkflow.darkflow.defaults import argHandler #Import the default arguments import os from darkflow.darkflow.net.build import TFNet

import tensorflow as tf

topdir = 'C:\Users\13067_000\Downloads\Videos' FLAGS = argHandler() FLAGS.setDefaults()

for dirpath, dirnames, files in os.walk(topdir): for name in files:

tf.reset_default_graph()

  FLAGS.demo = "C:\\Users\\13067_000\\Downloads\\Videos\\"+name# video file to use, or if camera just put "camera"
  FLAGS.model = "darkflow/cfg/yolo.cfg" # tensorflow model
  FLAGS.load = "darkflow/bin/yolo.weights" # tensorflow weights
  FLAGS.threshold = 0.5 # threshold of decetion confidance (detection if confidance > threshold )
  FLAGS.gpu = 0.75 #how much of the GPU to use (between 0 and 1) 0 means use cpu
  FLAGS.track = True # wheither to activate tracking or not
  FLAGS.trackObj = "person" # the object to be tracked
  FLAGS.saveVideo = True  #whether to save the video or not
  FLAGS.BK_MOG = False # activate background substraction using cv2 MOG substraction,
                            #to help in worst case scenarion when YOLO cannor predict(able to detect mouvement, it's not ideal but well)
                            # helps only when number of detection < 5, as it is still better than no detection.
  FLAGS.tracker = "deep_sort" # wich algorithm to use for tracking deep_sort/sort (NOTE : deep_sort only trained for people detection )
  FLAGS.skip = 3# how many frames to skipp between each detection to speed up the network
  FLAGS.csv = True #whether to write csv file or not(only when tracking is set to True)
  FLAGS.display = True # display the tracking or not
  tfnet = TFNet(FLAGS)       
  tfnet.camera()

exit('Demo stopped, exit.')

Error: ValueError: Variable conv1_1/weights already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at:

File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1470, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2956, in create_op op_def=op_def) File "C:\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper op_def=op_def)

Please help me in running darkflow for multiple videos

obendidi commented 6 years ago

check this issue : https://github.com/bendidi/Tracking-with-darkflow/issues/9

saranya-1 commented 6 years ago

I tried both the ways mentioned in Issue #9 but it still not working when i am trying to run for multiple videos. After here is my run.py and error .Please help in solving the issue. Where should I include tf.reset_default_graph()?

Run.py from darkflow.darkflow.defaults import argHandler #Import the default arguments import os from darkflow.darkflow.net.build import TFNet

topdir = 'D:\Videos' FLAGS = argHandler() FLAGS.setDefaults()

for root, dirs, files in os.walk(topdir, topdown=False): for name in files:

    FLAGS.demo = "D:\\Videos"+name# video file to use, or if camera just put "camera"
    FLAGS.model = "darkflow/cfg/yolo.cfg" # tensorflow model
    FLAGS.load = "darkflow/bin/yolo.weights" # tensorflow weights
    FLAGS.threshold = 0.5 # threshold of decetion confidance (detection if confidance > threshold )
    FLAGS.gpu = 0.75 #how much of the GPU to use (between 0 and 1) 0 means use cpu
    FLAGS.track = True # wheither to activate tracking or not
    FLAGS.trackObj = "person" # the object to be tracked
    FLAGS.saveVideo = True  #whether to save the video or not
    FLAGS.BK_MOG = False # activate background substraction using cv2 MOG substraction,
                            #to help in worst case scenarion when YOLO cannor predict(able to detect mouvement, it's not ideal but well)
                            # helps only when number of detection < 5, as it is still better than no detection.
    FLAGS.tracker = "deep_sort" # wich algorithm to use for tracking deep_sort/sort (NOTE : deep_sort only trained for people detection )
    FLAGS.skip = 3# how many frames to skipp between each detection to speed up the network
    FLAGS.csv = True #whether to write csv file or not(only when tracking is set to True)
    FLAGS.display = True # display the tracking or not
    tfnet = TFNet(FLAGS)         
    tfnet.camera()

exit('Demo stopped, exit.')


Error : Traceback (most recent call last): File "C:\Users\13067_000\Tracking-with-darkflow\run.py", line 30, in tfnet.camera() File "C:\Users\13067_000\Tracking-with-darkflow\darkflow\darkflow\net\help.py", line 83, in camera os.path.abspath("deep_sort/resources/networks/mars-small128.ckpt-68577")) File "C:\Users\13067_000\Tracking-with-darkflow\deep_sort\generate_detections.py", line 348, in create_box_encoder image_encoder = create_image_encoder(model_filename, batch_size, loss_mode) File "C:\Users\13067_000\Tracking-with-darkflow\deep_sort\generate_detections.py", line 343, in create_image_encoder model_filename, loss_mode) File "C:\Users\13067_000\Tracking-with-darkflow\deep_sort\generate_detections.py", line 314, in _create_image_encoder preprocessed_image_var, l2_normalize=l2_normalize, reuse=None) File "C:\Users\13067_000\Tracking-with-darkflow\deep_sort\generate_detections.py", line 224, in factory_fn weight_decay=weight_decay) File "C:\Users\13067_000\Tracking-with-darkflow\deep_sort\generate_detections.py", line 111, in _create_network weights_regularizer=conv_regularizer) File "C:\Python35\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py", line 181, in func_with_args return func(*args, current_args) File "C:\Python35\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py", line 1033, in convolution outputs = layer.apply(inputs) File "C:\Python35\lib\site-packages\tensorflow\python\layers\base.py", line 671, in apply return self.call(inputs, args, kwargs) File "C:\Python35\lib\site-packages\tensorflow\python\layers\base.py", line 559, in call self.build(input_shapes[0]) File "C:\Python35\lib\site-packages\tensorflow\python\layers\convolutional.py", line 143, in build dtype=self.dtype) File "C:\Python35\lib\site-packages\tensorflow\python\layers\base.py", line 458, in add_variable trainable=trainable and self.trainable) File "C:\Python35\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 1203, in get_variable constraint=constraint) File "C:\Python35\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 1092, in get_variable constraint=constraint) File "C:\Python35\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 417, in get_variable return custom_getter(custom_getter_kwargs) File "C:\Python35\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py", line 1539, in layer_variable_getter return _model_variable_getter(getter, args, kwargs) File "C:\Python35\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py", line 1531, in _model_variable_getter custom_getter=getter, use_resource=use_resource) File "C:\Python35\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py", line 181, in func_with_args return func(*args, *current_args) File "C:\Python35\lib\site-packages\tensorflow\contrib\framework\python\ops\variables.py", line 262, in model_variable use_resource=use_resource) File "C:\Python35\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py", line 181, in func_with_args return func(args, **current_args) File "C:\Python35\lib\site-packages\tensorflow\contrib\framework\python\ops\variables.py", line 217, in variable use_resource=use_resource) File "C:\Python35\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 394, in _true_getter use_resource=use_resource, constraint=constraint) File "C:\Python35\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 742, in _get_single_variable name, "".join(traceback.format_list(tb)))) ValueError: Variable conv1_1/weights already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at:

File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1470, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2956, in create_op op_def=op_def) File "C:\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper op_def=op_def)