matterport / Mask_RCNN

Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
24.52k stars 11.68k forks source link

Mask RCNN issue while importing - import tensorflow.python.keras.backend as K #1063

Closed ShibaPrasad closed 5 years ago

ShibaPrasad commented 5 years ago

OutPut Message:

AttributeError Traceback (most recent call last)

in () 29 from mrcnn import visualize 30 from mrcnn.visualize import display_images ---> 31 from mrcnn import model as modellib 32 from mrcnn.model import log 33 /project/bioinformatics/Rajaram_lab/s183574/myCopy/Nuclei-Counting-Segmentation/mrcnn/model.py in () 19 import tensorflow as tf 20 import tensorflow.python.keras ---> 21 import tensorflow.python.keras.backend as K 22 import tensorflow.python.keras.layers as KL 23 import tensorflow.python.keras.engine as KE AttributeError: module 'tensorflow' has no attribute 'python' -------------------------------------------------------------------------------------------------- Code: --------------------------------------------------------------------------------------------------- import os import sys import itertools import math import logging import json import re import random import time import concurrent.futures import numpy as np import matplotlib import matplotlib.pyplot as plt import matplotlib.patches as patches import matplotlib.lines as lines from matplotlib.patches import Polygon #import imgaug #from imgaug import augmenters as iaa # Root directory of the project ROOT_DIR = os.getcwd() if ROOT_DIR.endswith("samples/nucleus"): # Go up two levels to the repo root ROOT_DIR = os.path.dirname(os.path.dirname(ROOT_DIR)) # Import Mask RCNN sys.path.append(ROOT_DIR) from mrcnn import utils from mrcnn import visualize from mrcnn.visualize import display_images from mrcnn import model as modellib from mrcnn.model import log import nucleus %matplotlib inline
keineahnung2345 commented 5 years ago

I have checked https://github.com/matterport/Mask_RCNN/blob/master/mrcnn/model.py#L21, and it shows Line21 should be import keras.backend as K rather than import tensorflow.python.keras.backend as K. Maybe you should make your Mask_RCNN up to date.

ShibaPrasad commented 5 years ago

I have resolved it. that you

ShibaPrasad commented 5 years ago

i am getting below issue and totally stopped on my work: (would you please help me)

ValueError Traceback (most recent call last) /miniconda/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py in _apply_op_helper(self, op_type_name, name, **keywords) 509 as_ref=input_arg.is_ref, --> 510 preferred_dtype=default_dtype) 511 except TypeError as err:

/miniconda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in internal_convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, ctx) 1106 if ret is None: -> 1107 ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) 1108

/miniconda/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py in _autopacking_conversion_function(v, dtype, name, as_ref) 959 return NotImplemented --> 960 return _autopacking_helper(v, inferred_dtype, name or "packed") 961

/miniconda/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py in _autopacking_helper(list_or_tuple, dtype, name) 921 elems_as_tensors.append( --> 922 constant_op.constant(elem, dtype=dtype, name=str(i))) 923 return gen_array_ops.pack(elems_as_tensors, name=scope)

/miniconda/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py in constant(value, dtype, shape, name, verify_shape) 195 tensor_util.make_tensor_proto( --> 196 value, dtype=dtype, shape=shape, verify_shape=verify_shape)) 197 dtype_value = attr_value_pb2.AttrValue(type=tensor_value.tensor.dtype)

/miniconda/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py in make_tensor_proto(values, dtype, shape, verify_shape) 423 if values is None: --> 424 raise ValueError("None values not supported.") 425 # if dtype is provided, forces numpy array to be the type

ValueError: None values not supported.