Multi-Camera-Live-Object-Tracking icon indicating copy to clipboard operation
Multi-Camera-Live-Object-Tracking copied to clipboard

module 'tensorflow' has no attribute 'Session'

Open R33s3 opened this issue 3 years ago • 4 comments

I am getting the following error when attempting to run this application.

Any ideas as to what is going on (what I am doing wrong)?

  • Serving Flask app "app" (lazy loading)
  • Environment: production [31m WARNING: This is a development server. Do not use it in a production deployment.[0m [2m Use a production WSGI server instead.[0m
  • Debug mode: off
  • Running on http://0.0.0.0:5000/ (Press CTRL+C to quit) 127.0.0.1 - - [11/Mar/2021 16:23:21] "[37mGET / HTTP/1.1[0m" 200 - Using TensorFlow backend. Starting YOLO thread for device 0.Starting YOLO thread for device 1.

Stopping YOLO thread for device 0 due to error.Stopping YOLO thread for device 1 due to error. [2021-03-11 16:23:23,842] ERROR in app: Exception on /video_feed/yolo/0 [GET] Traceback (most recent call last): File "/home/user/.local/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/home/user/.local/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/user/.local/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/user/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/user/.local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/home/user/.local/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functionsrule.endpoint File "/home/user/Downloads/Multi-Camera-Live-Object-Tracking-master/traffic_counting/app.py", line 60, in video_feed return Response(gen(camera_stream=camera_stream(feed_type, device, port_list), feed_type=feed_type, device=device), File "/home/user/Downloads/Multi-Camera-Live-Object-Tracking-master/traffic_counting/camera_yolo.py", line 24, in init super(Camera, self).init(feed_type, device, port_list) File "/home/user/Downloads/Multi-Camera-Live-Object-Tracking-master/traffic_counting/base_camera.py", line 78, in init while self.get_frame(self.unique_name) is None: File "/home/user/Downloads/Multi-Camera-Live-Object-Tracking-master/traffic_counting/base_camera.py", line 90, in get_frame return BaseCamera.frame[unique_name] KeyError: ('yolo', '0')

module 'tensorflow' has no attribute 'Session'127.0.0.1 - - [11/Mar/2021 16:23:23] "[1m[35mGET /video_feed/yolo/0 HTTP/1.1[0m" 500 - [2021-03-11 16:23:23,843] ERROR in app: Exception on /video_feed/yolo/1 [GET] Traceback (most recent call last): File "/home/user/.local/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/home/user/.local/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/user/.local/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/user/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/user/.local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/home/user/.local/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functionsrule.endpoint File "/home/user/Downloads/Multi-Camera-Live-Object-Tracking-master/traffic_counting/app.py", line 60, in video_feed return Response(gen(camera_stream=camera_stream(feed_type, device, port_list), feed_type=feed_type, device=device), File "/home/user/Downloads/Multi-Camera-Live-Object-Tracking-master/traffic_counting/camera_yolo.py", line 24, in init super(Camera, self).init(feed_type, device, port_list) File "/home/user/Downloads/Multi-Camera-Live-Object-Tracking-master/traffic_counting/base_camera.py", line 78, in init while self.get_frame(self.unique_name) is None: File "/home/user/Downloads/Multi-Camera-Live-Object-Tracking-master/traffic_counting/base_camera.py", line 90, in get_frame return BaseCamera.frame[unique_name] KeyError: ('yolo', '1') module 'tensorflow' has no attribute 'Session' 127.0.0.1 - - [11/Mar/2021 16:23:23] "[1m[35mGET /video_feed/yolo/1 HTTP/1.1[0m" 500 -

R33s3 avatar Mar 11 '21 21:03 R33s3

I guess it's a tensorflow version problem. This repo seems dependent on TF-1.14. Did you run it on TF2?

HaebinShin avatar Mar 18 '21 12:03 HaebinShin

Yes, the error could be due to the tensorflow version. Could you try running it with the same dependencies as mine and see if the same error still occurs?

LeonLok avatar Mar 18 '21 18:03 LeonLok

Tensorflow version 2 can't use session. Try to change tf.Session to tf.compat.v1.Session to get the same result. Besides when you use Keras.get_session() change that to tf.compat.v1.keras.backend.get_session(). Good luck

tomklaver1995 avatar Mar 24 '21 11:03 tomklaver1995

I can not seem to get version 1 of tensorflow installed anymore. Does anyone know how to install tensorflow-gpu Version 1?

For example when I run - sudo pip3 install "tensorflow-gpu>=1.14,<2.0" ERROR: Could not find a version that satisfies the requirement tensorflow-gpu<2.0,>=1.14 (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.2.1, 2.2.2, 2.3.0rc0, 2.3.0rc1, 2.3.0rc2, 2.3.0, 2.3.1, 2.3.2, 2.4.0rc0, 2.4.0rc1, 2.4.0rc2, 2.4.0rc3, 2.4.0rc4, 2.4.0, 2.4.1) ERROR: No matching distribution found for tensorflow-gpu<2.0,>=1.14

sudo pip3 install tensorflow-gpu==1.14.0 ERROR: Could not find a version that satisfies the requirement tensorflow-gpu==1.14.0 (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.2.1, 2.2.2, 2.3.0rc0, 2.3.0rc1, 2.3.0rc2, 2.3.0, 2.3.1, 2.3.2, 2.4.0rc0, 2.4.0rc1, 2.4.0rc2, 2.4.0rc3, 2.4.0rc4, 2.4.0, 2.4.1) ERROR: No matching distribution found for tensorflow-gpu==1.14.0

R33s3 avatar Mar 29 '21 20:03 R33s3