OlafenwaMoses / ImageAIDocumentation

Official English Documentation of ImageAI
MIT License
23 stars 30 forks source link

'tensorflow' has no attribute 'get_default_session' #7

Open IFV opened 4 years ago

IFV commented 4 years ago

Hi!

I am using the example from the official documentation [1]. Here is my script:


from imageai.Detection import ObjectDetection import os

execution_path = os.getcwd()

detector = ObjectDetection() detector.setModelTypeAsYOLOv3() detector.setModelPath( os.path.join(execution_path , "yolo.h5")) detector.loadModel() detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "test.jpg"), output_image_path=os.path.join(execution_path , "test_new.jpg"), minimum_percentage_probability=30)

for eachObject in detections: print(eachObject["name"] , " : ", eachObject["percentage_probability"], " : ", eachObject["box_points"] ) print("--------------------------------")


The error I'm getting is:

AttributeError: module 'tensorflow' has no attribute 'get_default_session'

Using: python=v3.7.6 tensorflow=v2.2.0 keras=v2.2.4 [1] https://imageai.readthedocs.io/en/latest/index.html

sarahucl94 commented 3 years ago

Hi, I had the same exact error. I was using the following versions:

python 3.7.4 tensorflow 2.3.0 keras 2.4.3

Solved it by downgrading tensorflow to 1.13.1 and keras to 2.2.4. However, that causes issues with other packages I have installed (eg. jrpytensorflow) that need later versions. Hope this helps for now.