ahmetozlu / tensorflow_object_counting_api

🚀 The TensorFlow Object Counting API is an open source framework built on top of TensorFlow and Keras that makes it easy to develop object counting systems!
https://www.youtube.com/watch?v=yT_1eKJTdfk
MIT License
1.32k stars 546 forks source link

Error while running single_image_object_counting.py #22

Closed jiansheng77 closed 5 years ago

jiansheng77 commented 5 years ago

Hi. I am trying to run the single_image_object_counting.py file but i keep running into Runtimeerror: Attempted to use a closed session.

I saw the other threads and tried changing the object detection api file but it didnt work as well. I am trying to count the number of dogs and cats using my own test data.

Traceback (most recent call last): File "C:\tensorflow1\model\research\object_detection\single_image_object_counting.py", line 26, in result = object_counting_api.single_image_object_counting(input_video, detection_graph, category_index, is_color_recognition_enabled, fps, width, height) # targeted objects counting File "C:\tensorflow1\model\research\object_detection\api\object_counting_api.py", line 475, in single_image_object_counting counter, csv_line, counting_mode = vis_util.visualize_boxes_and_labels_on_single_image_array(1,input_frame, AttributeError: module 'utils.visualization_utils' has no attribute 'visualize_boxes_and_labels_on_single_image_array'

Can you help me please

zazizou commented 5 years ago

Hi,

I am actually struggling with similar issues with single_image_object_counting.py. I did not change the default file.

Here are my logs

Traceback (most recent call last): File "single_image_object_counting.py", line 27, in result = object_counting_api.single_image_object_counting(input_video, detection_graph, category_index, is_color_recognition_enabled, fps, width, height) # targeted objects counting File "/home/momo/WorkSpace/tensorflow_object_counting_api/api/object_counting_api.py", line 471, in single_image_object_counting feed_dict={image_tensor: image_np_expanded}) File "/home/momo/.virtualenvs/pywork/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 929, in run run_metadata_ptr) File "/home/momo/.virtualenvs/pywork/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1075, in _run raise RuntimeError('Attempted to use a closed Session.') RuntimeError: Attempted to use a closed Session.

Thanks in advance

finalwind commented 5 years ago

I fix this with indenting line 471 onward in object_counting_api.py, it need to be inside the session

zazizou commented 5 years ago

Do you mean line 461 ?

input_frame = cv2.imread(input_video)

finalwind commented 5 years ago

Yes you are right. Sorry I don't exactly remember the line number.

ahmetozlu commented 5 years ago

thanks for your support @finalwind !