Closed sureshbona closed 7 years ago
this is because you try to create two graphs with the same name variables :
tfnet = TFNet(FLAGS)
in each function call you are trying to create a new graph while leaving the old one open
tf.reset_default_graph()
before each call to reset the default graph (this a very bad/crude way to do it , and don't know if it'll work )darkflow/darkflow/net/help.py
change the camera function from :
def camera(self):
file = self.FLAGS.demo
SaveVideo = self.FLAGS.saveVideo
to
def camera(self,file):
SaveVideo = self.FLAGS.saveVideo
and then in run.py it will be like this :
from darkflow.darkflow.defaults import argHandler #Import the default arguments
import os
from darkflow.darkflow.net.build import TFNet
FLAGS = argHandler()
FLAGS.setDefaults()
FLAGS.model = "darkflow/cfg/yolo.cfg" # tensorflow model
FLAGS.load = "darkflow/bin/yolo.weights" # tensorflow weights
FLAGS.threshold = 0.25 # 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 = False #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 = 0 # 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 = False # display the tracking or not
tfnet = TFNet(FLAGS)
print("Running for the first time")
tfnet.camera("data/test_1.avi")
print("Running for the second time")
tfnet.camera("data/test_2.avi")
Hope it helps !
Thank you @bendidi. The first method worked for me and the second method gave the same error.
Hi
I have modified run.py by defining a function run(videoPath) which takes video as an input and assign that to FLAGS.demo and runs the original Tracking-with-darkflow.
Now, If I call this run(videoPath) for the first time it runs properly but for the second time, it throws the error.
I have attached code and error to this post. Can you please help in solving this error.
Thanks in advance.