matterport / Mask_RCNN

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

Recommended keras version incompatible #2587

Open Radhika-Keni opened 3 years ago

Radhika-Keni commented 3 years ago

Hi , I am in the process of implementing this library . I am using the following(recommended by matterport) versions of keras & Tensor flow .Code is being executed on Google Colab.

Keras: 2.5.0 Tensor Flow :2.50

I am getting the following error

AttributeError Traceback (most recent call last)

in () 1 # define the model ----> 2 from mrcnn.model import MaskRCNN 3 4 # model_dir is where want intermediate models to be saved , lest use "workingdirectory" path that we created 5 model = MaskRCNN(mode='training', model_dir=filepath, config=config) /content/Mask_RCNN/mrcnn/model.py in () 253 254 --> 255 class ProposalLayer(KE.Layer): 256 """Receives anchor scores and selects a subset to pass as proposals 257 to the second stage. Filtering is done based on anchor scores and **AttributeError: module 'keras.engine' has no attribute 'Layer'** Please advice why this issue would be cropping up and what we can do resolve it ? [Github.docx](https://github.com/matterport/Mask_RCNN/files/6592450/Github.docx)
uxairibrar commented 3 years ago

Hey if you got the solution can you please share it? I'm also having a lot of issues in compatible version

Radhika-Keni commented 3 years ago

Hi , Yes there is a temporary solution . Use tensor flow 1.15.3 and keras 2.2.4( acknowledgement for the fix to to Dr. Jason Brownlee). This will resolve all the issues mentioned in the error above.

However , I would still call this issue out as an open issue and request Matter port team to please fix it .MaskRCNN library built is not upward compatible , please look into this

John-Polo commented 3 years ago

Also in Google Colab, using the following:

!git clone --quiet https://github.com/matterport/Mask_RCNN.git
!pip install -r requirements.txt
!python setup.py install

and then

import mrcnn.model as modellib I get the same exact AttributeError about "no Layer".

The setup/install (the GIT clone and requirements) uses keras and tensorflow 2.5.0. I don't know how to tell Colab to change the versions to something else, as the comment by @Radhika-Keni suggests.

Radhika-Keni commented 3 years ago

There is a bug on Google colab due to a recent upgrade that happened at their end (maybe 2 weeks ago). The impact of the bug is that it does not allow us to downgrade keras version. Google colab has provided a temporary solution for this issue , here is the solution provided by google https://github.com/googlecolab/colabtools/issues/2068 I hope this helps you guys get unblocked

nataliameira commented 3 years ago

@Radhika-Keni Hey I trained my model and visualized the data. My training was held on June 3, 2021. I used:

pip uninstall keras-nightly pip uninstall -y tensorflow h5py==2.10.0 tensorflow==1.15 tensorflow-gpu==1.15.0 keras==2.1.6

Radhika-Keni commented 3 years ago

Great !

huaibovip commented 3 years ago

!pip uninstall keras -y !pip uninstall keras-nightly -y !pip uninstall keras-Preprocessing -y !pip uninstall keras-vis -y !pip uninstall tensorflow -y !pip uninstall h5py -y

!pip install tensorflow==1.13.1 !pip install keras==2.0.8 !pip install h5py==2.10.0

Nouman945 commented 3 years ago

2.0.8

ERROR: Could not find a version that satisfies the requirement tensorflow==1.13.1 (from versions: 2.5.0rc0, 2.5.0rc1, 2.5.0rc2, 2.5.0rc3, 2.5.0, 2.5.1, 2.6.0rc0, 2.6.0rc1, 2.6.0rc2, 2.6.0) ERROR: No matching distribution found for tensorflow==1.13.1

nataliameira commented 3 years ago

Hi @Nouman945 look this

@Radhika-Keni Hey I trained my model and visualized the data. My training was held on June 3, 2021. I used:

pip uninstall keras-nightly pip uninstall -y tensorflow h5py==2.10.0 tensorflow==1.15 tensorflow-gpu==1.15.0 keras==2.1.6

Aisharjaa commented 3 years ago

@Radhika-Keni Hey I trained my model and visualized the data. My training was held on June 3, 2021. I used:

pip uninstall keras-nightly pip uninstall -y tensorflow h5py==2.10.0 tensorflow==1.15 tensorflow-gpu==1.15.0 keras==2.1.6

how did u train ur model? can u help me with ur script?

nataliameira commented 3 years ago

@Aisharjaa I did a custom model of the balloon.py example.

sauravsolanki commented 3 years ago

Find my answer here: https://github.com/matterport/Mask_RCNN/issues/2666#issuecomment-906773778

sergiizquierdobas commented 2 years ago

I'm having similar problems:

import mrcnn.model as modellib

class ProposalLayer(KE.Layer): AttributeError: module 'keras.engine' has no attribute 'Layer'

under-score commented 2 years ago

Having tried now the solutions posted above and at SO I can confirm that nothing works at the moment (using the "requirements.txt" in the distribution). Downgrading isn't even a solution as recommended before. Even if I can find a matching distribution I am running into other problems as for example spyder crashes after installing earlier tensorflow versions because spyder needs typing-extensions-4.0.1. and not typing-extensions 3.7.4. Please could the matterport team look into that issue? This error kills the whole approach.

Nouman945 commented 2 years ago

Having tried now numerous solutions posted here and at SO I can confirm that nothing works at the moment when using the "requirements.txt" in the distribution.

Downgrading isn't even a solution as recommended before. Even if I can find a matching distribution I am running into other problems as for example spyder crashes after installing tensorflow 2.5.2 because spyder needs typing-extensions-4.0.1. and not typing-extensions 3.7.4.

Please could the matterport team look into that issue as this error kills the whole approach.

I can help you set up your environment.

under-score commented 2 years ago

million thanks - how to proceed? Should I set up a new environment or do you have a Docker container?

Nouman945 commented 2 years ago

million thanks - how to proceed? Should I set up a new environment or do you have a Docker container?

Set up a fresh anaconda Environment using

conda create -n myenv python=3.6.13

Use tensorflow==1.15.0, Keras==2.2.4, h5py==2.8.0

These worked for me. Or you can reach out to me here directly. muhmmadnouman945@gmail.com

I'll be glad to help you.

under-score commented 2 years ago

my hero! just for posteriority

conda create --name myenv python=3.6.13 tensorflow==1.15.0 Keras==2.2.4 h5py==2.8.0 pip
conda activate myenv
git clone https://github.com/matterport/Mask_RCNN.git
cd  ~/Mask_RCNN-master
pip install -r requirements.txt
git clone https://github.com/philferriere/cocoapi.git
pip install pycocotools
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
wget https://github.com/matterport/Mask_RCNN/releases/download/v2.1/mask_rcnn_balloon.h5 > Mask_RCNN/mask_rcnn_balloon.h5
conda deactivate
Nouman945 commented 2 years ago

I'm glad this worked for You. let me know if you need help further.

On Tue, Dec 7, 2021 at 7:16 PM under-score @.***> wrote:

my hero! just for posteriority

conda create --name myenv python=3.6.13 tensorflow==1.15.0 Keras==2.2.4 h5py==2.8.0 pip conda activate myenv cd ~/Mask_RCNN-master pip install -r requirements.txt git clone https://github.com/matterport/Mask_RCNN.git git clone https://github.com/philferriere/cocoapi.git pip install pycocotools pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI wget "https://github.com/matterport/Mask_RCNN/releases/download/v2.1/mask_rcnn_balloon.h5" > Mask_RCNN/mask_rcnn_coco.h5 conda deactivate

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/matterport/Mask_RCNN/issues/2587#issuecomment-987966023, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMB72JQEKEQZQZWSDZ7E25LUPYJL5ANCNFSM46A6DQXA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

KatieGou commented 2 years ago

which python version did you use? I used 3.7.9 and followed your versions, but the same error still pops out.

under-score commented 2 years ago

scroll up -> 3.6.13

johannaengman commented 2 years ago

my hero! just for posteriority

conda create --name myenv python=3.6.13 tensorflow==1.15.0 Keras==2.2.4 h5py==2.8.0 pip
conda activate myenv
git clone https://github.com/matterport/Mask_RCNN.git
cd  ~/Mask_RCNN-master
pip install -r requirements.txt
git clone https://github.com/philferriere/cocoapi.git
pip install pycocotools
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
wget https://github.com/matterport/Mask_RCNN/releases/download/v2.1/mask_rcnn_balloon.h5 > Mask_RCNN/mask_rcnn_balloon.h5
conda deactivate

I did this but still got the same error. Any other ideas?

nataliameira commented 2 years ago

@Radhika-Keni Hey I trained my model and visualized the data. My training was held on June 3, 2021. I used:

pip uninstall keras-nightly pip uninstall -y tensorflow h5py==2.10.0 tensorflow==1.15 tensorflow-gpu==1.15.0 keras==2.1.6

Hi @johannaengman look this

Nouman945 commented 2 years ago

8.0

Can I see the error.?

rvbabera commented 1 year ago

@Radhika-Keni Hey I trained my model and visualized the data. My training was held on June 3, 2021. I used:

pip uninstall keras-nightly pip uninstall -y tensorflow h5py==2.10.0 tensorflow==1.15 tensorflow-gpu==1.15.0 keras==2.1.6

Hey @nataliameira I am using this method on 16 Feb 2023 and I am getting this error please help ERROR: No matching distribution found for tensorflow==1.15.0

ERROR: No matching distribution found for keras==2.16

mathhauk commented 1 year ago

@Radhika-Keni Hey I trained my model and visualized the data. My training was held on June 3, 2021. I used: pip uninstall keras-nightly pip uninstall -y tensorflow h5py==2.10.0 tensorflow==1.15 tensorflow-gpu==1.15.0 keras==2.1.6

Hey @nataliameira I am using this method on 16 Feb 2023 and I am getting this error please help ERROR: No matching distribution found for tensorflow==1.15.0

ERROR: No matching distribution found for keras==2.16

Have you found out about this? I have the same problem..

Radhika-Keni commented 1 year ago

Google colab no longer supports tensor flow 1.X ,check this stackoverflow link on the same https://stackoverflow.com/questions/73215696/did-colab-suspend-tensorflow-1-x

On Tue, Feb 28, 2023 at 7:58 PM mathhauk @.***> wrote:

@Radhika-Keni https://github.com/Radhika-Keni Hey I trained my model and visualized the data. My training was held on June 3, 2021. I used: pip uninstall keras-nightly pip uninstall -y tensorflow h5py==2.10.0 tensorflow==1.15 tensorflow-gpu==1.15.0 keras==2.1.6

Hey @nataliameira https://github.com/nataliameira I am using this method on 16 Feb 2023 and I am getting this error please help ERROR: No matching distribution found for tensorflow==1.15.0

ERROR: No matching distribution found for keras==2.16

Have you found out about this? I have the same problem..

— Reply to this email directly, view it on GitHub https://github.com/matterport/Mask_RCNN/issues/2587#issuecomment-1448280597, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQJXEKK67YOGBPXGP4QGQ53WZYDQ3ANCNFSM46A6DQXA . You are receiving this because you were mentioned.Message ID: @.***>

nataliameira commented 1 year ago

hey, @rvbabera

I trained the model on my local machine. At the time, I remember that I managed to run on the colab, but it was very difficult. I don't remember how to resolve these errors. I am really sorry.