简体   繁体   中英

How to fix this AttributeError: module 'tensorflow' has no attribute 'get_default_graph'?

My tensorflow version=2.0.0,keras version=2.1.5,python version=3.7

code:

import os
import cv2
import numpy as np
import argparse
import json
       
from PIL import Image
from mtcnn import MTCNN
detector = MTCNN()

return a error as like:

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

A lot of the newer versions of Tensorflow have inconsistencies.

Try either downgrading your tensorflow version pip install tensorflow==1.13.1

or upgrading your Keras to something 2.3 or above pip install -U keras

If you're brave you could also go digging to find which python file has a line like import keras.something.something and change it to import tensorflow.keras.something

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM