Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module 'tensorflow' has no attribute 'Session' #31

Open
R33s3 opened this issue Mar 11, 2021 · 4 comments
Open

module 'tensorflow' has no attribute 'Session' #31

R33s3 opened this issue Mar 11, 2021 · 4 comments

Comments

@R33s3
Copy link

R33s3 commented Mar 11, 2021

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 -

@HaebinShin
Copy link

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

@LeonLok
Copy link
Owner

LeonLok commented Mar 18, 2021

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?

@tomklaver1995
Copy link

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

@R33s3
Copy link
Author

R33s3 commented Mar 29, 2021

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 R33s3 closed this as completed Mar 29, 2021
@R33s3 R33s3 reopened this Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants