i am getting error in the tensorflow python code running in spyder ?

I made an object classifier that classifies objects and gives predictions. It is working fine with images but when i am giving it a video input and running that on every 5 frames in the video, after a certain time it stops giving the error as given below:

My Error:

File “/home/shorav/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py”, line 2324, in _as_graph_def

raise ValueError(“GraphDef cannot be larger than 2GB.”)

ValueError: GraphDef cannot be larger than 2GB.

My Code:

import tensorflow as tf

import cv2

fn_list=

Capture video from file

cap = cv2.VideoCapture(‘combined.mp4’)

Frame_number=0

while True:

ret, frame = cap.read()

if ret == True:

Frame_number+=1

fn_list.append(Frame_number)

print “frame number is :”, Frame_number

gray = cv2.cvtColor(frame,cv2.COLOR_RGB2GRAY)

cv2.imshow(‘frame’,gray)

if (Frame_number%5==0):

cv2.imwrite(‘new_capture.jpg’,frame)

image_path = ‘/home/shorav/tfClassifier/new_capture.jpg’

image_data = tf.gfile.FastGFile(image_path, ‘rb’).read()

label_lines = [line.rstrip() for line

in tf.gfile.GFile(“final_labels.txt”)]

with tf.gfile.FastGFile("./final_graph.pb", ‘rb’) as f:

graph_def = tf.GraphDef()

graph_def.ParseFromString(f.read())

_ = tf.import_graph_def(graph_def, name=’’)

with tf.Session() as sess:

softmax_tensor = sess.graph.get_tensor_by_name(‘final_result:0’)

predictions = sess.run(softmax_tensor, \

{‘DecodeJpeg/contents:0’: image_data})

top_k = predictions[0].argsort()[-len(predictions[0]):][::-1]

score_results=

final_label=

for node_id in top_k:

human_string = label_lines[node_id]

score = predictions[0][node_id]

print(’%s (score = %.5f)’ % (human_string, score))

score_results.append(score)

final_label.append(human_string)

if cv2.waitKey(50) & 0xFF == ord(‘q’):

break

else:

break

cap.release()

cv2.destroyAllWindows()

Hi,

You have posted to the wrong mailing list. This is the mailing list for Bokeh, which is a visualization library, and nothing to do with tensor flow.

Thanks,

Bryan

···

On Oct 20, 2017, at 19:59, shorav suriyal [email protected] wrote:

I made an object classifier that classifies objects and gives predictions. It is working fine with images but when i am giving it a video input and running that on every 5 frames in the video, after a certain time it stops giving the error as given below:

My Error:

File “/home/shorav/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py”, line 2324, in _as_graph_def

raise ValueError(“GraphDef cannot be larger than 2GB.”)

ValueError: GraphDef cannot be larger than 2GB.

My Code:

import tensorflow as tf

import cv2

fn_list=

Capture video from file

cap = cv2.VideoCapture(‘combined.mp4’)

Frame_number=0

while True:

ret, frame = cap.read()

if ret == True:

Frame_number+=1

fn_list.append(Frame_number)

print “frame number is :”, Frame_number

gray = cv2.cvtColor(frame,cv2.COLOR_RGB2GRAY)

cv2.imshow(‘frame’,gray)

if (Frame_number%5==0):

cv2.imwrite(‘new_capture.jpg’,frame)

image_path = ‘/home/shorav/tfClassifier/new_capture.jpg’

image_data = tf.gfile.FastGFile(image_path, ‘rb’).read()

label_lines = [line.rstrip() for line

in tf.gfile.GFile(“final_labels.txt”)]

with tf.gfile.FastGFile("./final_graph.pb", ‘rb’) as f:

graph_def = tf.GraphDef()

graph_def.ParseFromString(f.read())

_ = tf.import_graph_def(graph_def, name=’’)

with tf.Session() as sess:

softmax_tensor = sess.graph.get_tensor_by_name(‘final_result:0’)

predictions = sess.run(softmax_tensor, \

{‘DecodeJpeg/contents:0’: image_data})

top_k = predictions[0].argsort()[-len(predictions[0]):][::-1]

score_results=

final_label=

for node_id in top_k:

human_string = label_lines[node_id]

score = predictions[0][node_id]

print(’%s (score = %.5f)’ % (human_string, score))

score_results.append(score)

final_label.append(human_string)

if cv2.waitKey(50) & 0xFF == ord(‘q’):

break

else:

break

cap.release()

cv2.destroyAllWindows()

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/130d7bdd-a94e-44d7-a935-bb897a4f6a30%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

<error 1>

i understand that but if anyone knows this error please help me out i am really in difficult situation ?

···

On Fri, Oct 20, 2017 at 6:21 PM, Bryan Van de ven [email protected] wrote:

Hi,

You have posted to the wrong mailing list. This is the mailing list for Bokeh, which is a visualization library, and nothing to do with tensor flow.

Thanks,

Bryan

On Oct 20, 2017, at 19:59, shorav suriyal [email protected] wrote:

I made an object classifier that classifies objects and gives predictions. It is working fine with images but when i am giving it a video input and running that on every 5 frames in the video, after a certain time it stops giving the error as given below:

My Error:

File “/home/shorav/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py”, line 2324, in _as_graph_def

raise ValueError(“GraphDef cannot be larger than 2GB.”)

ValueError: GraphDef cannot be larger than 2GB.

My Code:

import tensorflow as tf

import cv2

fn_list=

Capture video from file

cap = cv2.VideoCapture(‘combined.mp4’)

Frame_number=0

while True:

ret, frame = cap.read()

if ret == True:

Frame_number+=1

fn_list.append(Frame_number)

print “frame number is :”, Frame_number

gray = cv2.cvtColor(frame,cv2.COLOR_RGB2GRAY)

cv2.imshow(‘frame’,gray)

if (Frame_number%5==0):

cv2.imwrite(‘new_capture.jpg’,frame)

image_path = ‘/home/shorav/tfClassifier/new_capture.jpg’

image_data = tf.gfile.FastGFile(image_path, ‘rb’).read()

label_lines = [line.rstrip() for line

in tf.gfile.GFile(“final_labels.txt”)]

with tf.gfile.FastGFile("./final_graph.pb", ‘rb’) as f:

graph_def = tf.GraphDef()

graph_def.ParseFromString(f.read())

_ = tf.import_graph_def(graph_def, name=’’)

with tf.Session() as sess:

softmax_tensor = sess.graph.get_tensor_by_name(‘final_result:0’)

predictions = sess.run(softmax_tensor, \

{‘DecodeJpeg/contents:0’: image_data})

top_k = predictions[0].argsort()[-len(predictions[0]):][::-1]

score_results=

final_label=

for node_id in top_k:

human_string = label_lines[node_id]

score = predictions[0][node_id]

print(’%s (score = %.5f)’ % (human_string, score))

score_results.append(score)

final_label.append(human_string)

if cv2.waitKey(50) & 0xFF == ord(‘q’):

break

else:

break

cap.release()

cv2.destroyAllWindows()

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/130d7bdd-a94e-44d7-a935-bb897a4f6a30%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

<error 1>

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/78E0E41F-5E61-4C2F-BE84-B16099FF249B%40anaconda.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

I appreciate that you have a problem to solve, and I hope you are able to find a solution, but please know that intentionally spamming off-topic questions to the wrong mailing lists is a waste of people’s scarce time and attention and is not cool.

Bryan

···

On Oct 20, 2017, at 20:21, Bryan Van de ven [email protected] wrote:

Hi,

You have posted to the wrong mailing list. This is the mailing list for Bokeh, which is a visualization library, and nothing to do with tensor flow.

Thanks,

Bryan

On Oct 20, 2017, at 19:59, shorav suriyal [email protected] wrote:

I made an object classifier that classifies objects and gives predictions. It is working fine with images but when i am giving it a video input and running that on every 5 frames in the video, after a certain time it stops giving the error as given below:

My Error:

File “/home/shorav/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py”, line 2324, in _as_graph_def

raise ValueError(“GraphDef cannot be larger than 2GB.”)

ValueError: GraphDef cannot be larger than 2GB.

My Code:

import tensorflow as tf

import cv2

fn_list=

Capture video from file

cap = cv2.VideoCapture(‘combined.mp4’)

Frame_number=0

while True:

ret, frame = cap.read()

if ret == True:

Frame_number+=1

fn_list.append(Frame_number)

print “frame number is :”, Frame_number

gray = cv2.cvtColor(frame,cv2.COLOR_RGB2GRAY)

cv2.imshow(‘frame’,gray)

if (Frame_number%5==0):

cv2.imwrite(‘new_capture.jpg’,frame)

image_path = ‘/home/shorav/tfClassifier/new_capture.jpg’

image_data = tf.gfile.FastGFile(image_path, ‘rb’).read()

label_lines = [line.rstrip() for line

in tf.gfile.GFile(“final_labels.txt”)]

with tf.gfile.FastGFile("./final_graph.pb", ‘rb’) as f:

graph_def = tf.GraphDef()

graph_def.ParseFromString(f.read())

_ = tf.import_graph_def(graph_def, name=’’)

with tf.Session() as sess:

softmax_tensor = sess.graph.get_tensor_by_name(‘final_result:0’)

predictions = sess.run(softmax_tensor, \

{‘DecodeJpeg/contents:0’: image_data})

top_k = predictions[0].argsort()[-len(predictions[0]):][::-1]

score_results=

final_label=

for node_id in top_k:

human_string = label_lines[node_id]

score = predictions[0][node_id]

print(’%s (score = %.5f)’ % (human_string, score))

score_results.append(score)

final_label.append(human_string)

if cv2.waitKey(50) & 0xFF == ord(‘q’):

break

else:

break

cap.release()

cv2.destroyAllWindows()

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/130d7bdd-a94e-44d7-a935-bb897a4f6a30%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

<error 1>