Magic
Magic

Reputation: 1

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

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

config = CustomConfig()
model = modellib.MaskRCNN (mode= "training", config=config, model_dir=DEFAULT_LOGS_DIR)
weights_path = COCO_WEIGHTS_PATH # Download weights file
if not os.path.exists(weights_path):
  utils.download_trained_weights(weights_path)
model.load_weights(weights_path, by_name=True, exclude=["mrcnn_class_logits", 
                                                        "mrcnn_bbox_fc","mrcnn_bbox", 
                                                        "mrcnn_mask"])

Can anyone please tell me how to fix this attribute error.

I am using

!pip install keras==2.2.5
%tensorflow_version 2.x

Upvotes: 0

Views: 570

Answers (2)

Mogli141
Mogli141

Reputation: 85

This might be the issue regarding python version and tensorflow version. I have tried mask rcnn on 3.8 python version but it didnt worked. for me below setup worked.

on python 3.6.0:

tensorflow==1.14.0
Keras==2.1.3
pycocotools==2.0.4
numpy==1.16.4
matplotlib==2.2.5

Upvotes: 0

user11717481
user11717481

Reputation: 1602

It is possible that the error is generated by the configuration that you use as a parameter config in MaskRCNN, which has some slight differences depending on the stages (test, training), you can find more information in coco.py

from mrcnn.config import Config
#...

class CocoConfig(Config): 
    NAME = "coco" 
    IMAGES_PER_GPU = 2 
    NUM_CLASSES = 1 + 80 

# ...
config = CocoConfig()
model = modellib.MaskRCNN(mode="training", config=config, model_dir=DEFAULT_LOGS_DIR)
weights_path = COCO_WEIGHTS_PATH
if not os.path.exists(weights_path):
    utils.download_trained_weights(weights_path)
model.load_weights(weights_path, by_name=True, exclude=["mrcnn_class_logits", 
                                                        "mrcnn_bbox_fc",
                                                        "mrcnn_bbox", 
                                                        "mrcnn_mask"]) 

no train

class InferenceConfig(CocoConfig): 
    GPU_COUNT = 1
    IMAGES_PER_GPU = 1
    DETECTION_MIN_CONFIDENCE = 0 

Upvotes: 0

Related Questions