Making object picklableTypeError: can't pickle _thread.lock objectsHow to sort a list of objects based on an attribute of the objects?How can I make a time delay in Python?How to know if an object has an attribute in PythonHow to make a chain of function decorators?How to make a flat list out of list of lists?What is the meaning of a single and a double underscore before an object name?In Python, how do I determine if an object is iterable?Determine the type of an object?null object in Python?Python class inherits object

How do I gain back my faith in my PhD degree?

How to tell a function to use the default argument values?

Gatling : Performance testing tool

Intersection Puzzle

Is the myth that if you can play one instrument, you can learn another instrument with ease true?

Can I run a new neutral wire to repair a broken circuit?

Why do I get two different answers for this counting problem?

What's the in-universe reasoning behind sorcerers needing material components?

What does “the session was packed” mean in this context?

Why no variance term in Bayesian logistic regression?

How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?

Am I breaking OOP practice with this architecture?

CAST throwing error when run in stored procedure but not when run as raw query

How to show a landlord what we have in savings?

Should I tell management that I intend to leave due to bad software development practices?

Dreadful Dastardly Diseases, or Always Atrocious Ailments

Bullying boss launched a smear campaign and made me unemployable

Why is this clock signal connected to a capacitor to gnd?

A category-like structure without composition?

How can saying a song's name be a copyright violation?

Size of subfigure fitting its content (tikzpicture)

How badly should I try to prevent a user from XSSing themselves?

Can my sorcerer use a spellbook only to collect spells and scribe scrolls, not cast?

Is it acceptable for a professor to tell male students to not think that they are smarter than female students?



Making object picklable


TypeError: can't pickle _thread.lock objectsHow to sort a list of objects based on an attribute of the objects?How can I make a time delay in Python?How to know if an object has an attribute in PythonHow to make a chain of function decorators?How to make a flat list out of list of lists?What is the meaning of a single and a double underscore before an object name?In Python, how do I determine if an object is iterable?Determine the type of an object?null object in Python?Python class inherits object













-2















I'm trying to do multiprocessing, but I'm facing type error object is not pickable
1. I'm using tensorflow
2. OpenCV
3. Numpy
4. Pandas



I have two classes detection of tensor flow and tracking using kalman filter.



I'm not sure how to make those objects picklable or how to trace them or know how to fix them.
I googled a lot on that issues, couldn't find anything find usefull



if __name__ == "__main__":
video_name = '2016-11-18_07-30-01.h264'

cap = cv2.VideoCapture(video_name)

det = detector.CarDetector()
car_tracker = Sort_Algorithm.Sort()
ped_tracker = Sort_Algorithm.Sort()
df_region, df_line = load_filter()
threadn = cv2.getNumberOfCPUs()
pool = Pool(processes=2)
pending = Queue()
threaded_mode = True

while True:
while pending.qsize() > 0:
res = pending.get()
cv2.imshow('video ', res)

if pending.qsize() < 2:
ret, frame = cap.read()
if threaded_mode:
t1 = time.time()
H = [-2.01134074616, -16.6502442427, -1314.05715739, -3.35391526592, -22.3546973012, 2683.63584335,
-0.00130731963137, -0.0396207582264, 1]
matrix = np.reshape(H, (3, 3))
dst = cv2.warpPerspective(frame.copy(), matrix, (frame.shape[1], frame.shape[0]))
task = pool.apply_async(pipeline,
(frame.copy(), car_tracker, ped_tracker, df_region, df_line, det, dst, matrix))

cv2.imshow('dst', dst)
else:
task = DummyTask(pipeline,
(frame.copy(), car_tracker, ped_tracker, df_region, df_line, det, dst, matrix))

pending.put(task)
ch = cv2.waitKey(1)
if ch == ord(' '):
threaded_mode = not threaded_mode
if ch == 27:
break




class DummyTask:
def __init__(self, data):
self.data = data
def ready(self):
return True
def get(self):
return self.data









share|improve this question
























  • share DummyTask() code. Picking has strict rules, for an object being pickable all its attributes need to be pickable. Checkout the docs: docs.python.org/3/library/…

    – geckos
    Mar 21 at 22:09











  • @geckos I shared the DummyTask()

    – Waleed Saleh
    Mar 22 at 8:13











  • You are passing 2 parameters to DummyTask, but only declared one? You can try to pickle.dumps(DummyTask(...)) with the same parameters and see if you got a error

    – geckos
    Mar 22 at 10:20











  • still TypeError: can't pickle _thread.lock objects

    – Waleed Saleh
    Mar 22 at 10:48











  • Now we have something. I guess _thread.lock is coming from pipeline?

    – geckos
    Mar 22 at 12:39















-2















I'm trying to do multiprocessing, but I'm facing type error object is not pickable
1. I'm using tensorflow
2. OpenCV
3. Numpy
4. Pandas



I have two classes detection of tensor flow and tracking using kalman filter.



I'm not sure how to make those objects picklable or how to trace them or know how to fix them.
I googled a lot on that issues, couldn't find anything find usefull



if __name__ == "__main__":
video_name = '2016-11-18_07-30-01.h264'

cap = cv2.VideoCapture(video_name)

det = detector.CarDetector()
car_tracker = Sort_Algorithm.Sort()
ped_tracker = Sort_Algorithm.Sort()
df_region, df_line = load_filter()
threadn = cv2.getNumberOfCPUs()
pool = Pool(processes=2)
pending = Queue()
threaded_mode = True

while True:
while pending.qsize() > 0:
res = pending.get()
cv2.imshow('video ', res)

if pending.qsize() < 2:
ret, frame = cap.read()
if threaded_mode:
t1 = time.time()
H = [-2.01134074616, -16.6502442427, -1314.05715739, -3.35391526592, -22.3546973012, 2683.63584335,
-0.00130731963137, -0.0396207582264, 1]
matrix = np.reshape(H, (3, 3))
dst = cv2.warpPerspective(frame.copy(), matrix, (frame.shape[1], frame.shape[0]))
task = pool.apply_async(pipeline,
(frame.copy(), car_tracker, ped_tracker, df_region, df_line, det, dst, matrix))

cv2.imshow('dst', dst)
else:
task = DummyTask(pipeline,
(frame.copy(), car_tracker, ped_tracker, df_region, df_line, det, dst, matrix))

pending.put(task)
ch = cv2.waitKey(1)
if ch == ord(' '):
threaded_mode = not threaded_mode
if ch == 27:
break




class DummyTask:
def __init__(self, data):
self.data = data
def ready(self):
return True
def get(self):
return self.data









share|improve this question
























  • share DummyTask() code. Picking has strict rules, for an object being pickable all its attributes need to be pickable. Checkout the docs: docs.python.org/3/library/…

    – geckos
    Mar 21 at 22:09











  • @geckos I shared the DummyTask()

    – Waleed Saleh
    Mar 22 at 8:13











  • You are passing 2 parameters to DummyTask, but only declared one? You can try to pickle.dumps(DummyTask(...)) with the same parameters and see if you got a error

    – geckos
    Mar 22 at 10:20











  • still TypeError: can't pickle _thread.lock objects

    – Waleed Saleh
    Mar 22 at 10:48











  • Now we have something. I guess _thread.lock is coming from pipeline?

    – geckos
    Mar 22 at 12:39













-2












-2








-2








I'm trying to do multiprocessing, but I'm facing type error object is not pickable
1. I'm using tensorflow
2. OpenCV
3. Numpy
4. Pandas



I have two classes detection of tensor flow and tracking using kalman filter.



I'm not sure how to make those objects picklable or how to trace them or know how to fix them.
I googled a lot on that issues, couldn't find anything find usefull



if __name__ == "__main__":
video_name = '2016-11-18_07-30-01.h264'

cap = cv2.VideoCapture(video_name)

det = detector.CarDetector()
car_tracker = Sort_Algorithm.Sort()
ped_tracker = Sort_Algorithm.Sort()
df_region, df_line = load_filter()
threadn = cv2.getNumberOfCPUs()
pool = Pool(processes=2)
pending = Queue()
threaded_mode = True

while True:
while pending.qsize() > 0:
res = pending.get()
cv2.imshow('video ', res)

if pending.qsize() < 2:
ret, frame = cap.read()
if threaded_mode:
t1 = time.time()
H = [-2.01134074616, -16.6502442427, -1314.05715739, -3.35391526592, -22.3546973012, 2683.63584335,
-0.00130731963137, -0.0396207582264, 1]
matrix = np.reshape(H, (3, 3))
dst = cv2.warpPerspective(frame.copy(), matrix, (frame.shape[1], frame.shape[0]))
task = pool.apply_async(pipeline,
(frame.copy(), car_tracker, ped_tracker, df_region, df_line, det, dst, matrix))

cv2.imshow('dst', dst)
else:
task = DummyTask(pipeline,
(frame.copy(), car_tracker, ped_tracker, df_region, df_line, det, dst, matrix))

pending.put(task)
ch = cv2.waitKey(1)
if ch == ord(' '):
threaded_mode = not threaded_mode
if ch == 27:
break




class DummyTask:
def __init__(self, data):
self.data = data
def ready(self):
return True
def get(self):
return self.data









share|improve this question
















I'm trying to do multiprocessing, but I'm facing type error object is not pickable
1. I'm using tensorflow
2. OpenCV
3. Numpy
4. Pandas



I have two classes detection of tensor flow and tracking using kalman filter.



I'm not sure how to make those objects picklable or how to trace them or know how to fix them.
I googled a lot on that issues, couldn't find anything find usefull



if __name__ == "__main__":
video_name = '2016-11-18_07-30-01.h264'

cap = cv2.VideoCapture(video_name)

det = detector.CarDetector()
car_tracker = Sort_Algorithm.Sort()
ped_tracker = Sort_Algorithm.Sort()
df_region, df_line = load_filter()
threadn = cv2.getNumberOfCPUs()
pool = Pool(processes=2)
pending = Queue()
threaded_mode = True

while True:
while pending.qsize() > 0:
res = pending.get()
cv2.imshow('video ', res)

if pending.qsize() < 2:
ret, frame = cap.read()
if threaded_mode:
t1 = time.time()
H = [-2.01134074616, -16.6502442427, -1314.05715739, -3.35391526592, -22.3546973012, 2683.63584335,
-0.00130731963137, -0.0396207582264, 1]
matrix = np.reshape(H, (3, 3))
dst = cv2.warpPerspective(frame.copy(), matrix, (frame.shape[1], frame.shape[0]))
task = pool.apply_async(pipeline,
(frame.copy(), car_tracker, ped_tracker, df_region, df_line, det, dst, matrix))

cv2.imshow('dst', dst)
else:
task = DummyTask(pipeline,
(frame.copy(), car_tracker, ped_tracker, df_region, df_line, det, dst, matrix))

pending.put(task)
ch = cv2.waitKey(1)
if ch == ord(' '):
threaded_mode = not threaded_mode
if ch == 27:
break




class DummyTask:
def __init__(self, data):
self.data = data
def ready(self):
return True
def get(self):
return self.data






python multiprocessing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 8:13







Waleed Saleh

















asked Mar 21 at 21:26









Waleed SalehWaleed Saleh

85




85












  • share DummyTask() code. Picking has strict rules, for an object being pickable all its attributes need to be pickable. Checkout the docs: docs.python.org/3/library/…

    – geckos
    Mar 21 at 22:09











  • @geckos I shared the DummyTask()

    – Waleed Saleh
    Mar 22 at 8:13











  • You are passing 2 parameters to DummyTask, but only declared one? You can try to pickle.dumps(DummyTask(...)) with the same parameters and see if you got a error

    – geckos
    Mar 22 at 10:20











  • still TypeError: can't pickle _thread.lock objects

    – Waleed Saleh
    Mar 22 at 10:48











  • Now we have something. I guess _thread.lock is coming from pipeline?

    – geckos
    Mar 22 at 12:39

















  • share DummyTask() code. Picking has strict rules, for an object being pickable all its attributes need to be pickable. Checkout the docs: docs.python.org/3/library/…

    – geckos
    Mar 21 at 22:09











  • @geckos I shared the DummyTask()

    – Waleed Saleh
    Mar 22 at 8:13











  • You are passing 2 parameters to DummyTask, but only declared one? You can try to pickle.dumps(DummyTask(...)) with the same parameters and see if you got a error

    – geckos
    Mar 22 at 10:20











  • still TypeError: can't pickle _thread.lock objects

    – Waleed Saleh
    Mar 22 at 10:48











  • Now we have something. I guess _thread.lock is coming from pipeline?

    – geckos
    Mar 22 at 12:39
















share DummyTask() code. Picking has strict rules, for an object being pickable all its attributes need to be pickable. Checkout the docs: docs.python.org/3/library/…

– geckos
Mar 21 at 22:09





share DummyTask() code. Picking has strict rules, for an object being pickable all its attributes need to be pickable. Checkout the docs: docs.python.org/3/library/…

– geckos
Mar 21 at 22:09













@geckos I shared the DummyTask()

– Waleed Saleh
Mar 22 at 8:13





@geckos I shared the DummyTask()

– Waleed Saleh
Mar 22 at 8:13













You are passing 2 parameters to DummyTask, but only declared one? You can try to pickle.dumps(DummyTask(...)) with the same parameters and see if you got a error

– geckos
Mar 22 at 10:20





You are passing 2 parameters to DummyTask, but only declared one? You can try to pickle.dumps(DummyTask(...)) with the same parameters and see if you got a error

– geckos
Mar 22 at 10:20













still TypeError: can't pickle _thread.lock objects

– Waleed Saleh
Mar 22 at 10:48





still TypeError: can't pickle _thread.lock objects

– Waleed Saleh
Mar 22 at 10:48













Now we have something. I guess _thread.lock is coming from pipeline?

– geckos
Mar 22 at 12:39





Now we have something. I guess _thread.lock is coming from pipeline?

– geckos
Mar 22 at 12:39












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55289491%2fmaking-object-picklable%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55289491%2fmaking-object-picklable%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript