I'm trying plot my model on the google colab.
from keras.utils import plot_model
plot_model(model, to_file="model.png")
and I got this error:
ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.
I've installed pydot-ng and graphviz and I'm still can't get through this error.
To install pydot, run:
!pip install -q pydot
Then, restart your VM to reload keras which should then detect pydot's existence. (Runtime menu -> Restart runtime...)
Related
I'm trying to import imageai
from imageai.Detection import VideoObjectDetection
but get error message below
ModuleNotFoundError: No module named 'keras.layers.advanced_activations'
My tensorflow version 2.9.1,
keras version 2.9.0,
keras-preprocessing version 1.1.2,
image ai version 2.1.5,
I installed the imageai via pip install imageai-2.0.2-py3-none-any.whl and download from here.
The following code is an example for calling several types of advanced activation, Try to call it by
from keras.layers import ELU, PReLU, LeakyReLU
The import works with keras version 2.9.0 as below.
from keras.layers import LeakyReLU
I encountered the same error today. Downgrading my keras to 2.1.0 and tensorflow to 2.2.0 got rid of the error.
I faced the same error. ModuleNotFoundError: No module named 'keras.layers.advanced_activations'
To solve this problem:
Try to install TensorFlow 2.8.2 which is compatible with Keras 2.8.0
pip install tensorflow==2.8.2
Please install imageai using this link or use below code as you must install few libraries before installing imageai.
pip install cython pillow>=7.0.0 numpy>=1.18.1 opencv-python>=4.1.2 torch>=1.9.0 --extra-index-url https://download.pytorch.org/whl/cpu torchvision>=0.10.0 --extra-index-url https://download.pytorch.org/whl/cpu pytest==7.1.3 tqdm==4.64.1 scipy>=1.7.3 matplotlib>=3.4.3 mock==4.0.3
pip install imageai --upgrade
then import VideoObjectDetection as below:
from imageai.Detection import VideoObjectDetection
this:
import tensorflow as tf
from transformers import BertTokenizer, TFBertForSequenceClassification
model = TFBertForSequenceClassification.from_pretrained("bert-base-uncased")
Outputs the following error:
ImportError:
TFBertForSequenceClassification requires the TensorFlow library but it was not found in your environment. Checkout the instructions on the
installation page: https://www.tensorflow.org/install and follow the ones that match your environment.
However it's not true I don't have the TensorFlow library imported.
> print(tf.__version__)
'2.7.0'
As this is to answer the question when Tensorflow is indeed installed and imported this can often be a problem in this case.
BERT requires the tensorflow-gpu package so you need to have installed the tensorflow-gpu package to do what you are attempting here.
IF you are in a notebook run:
!pip install tensorflow-gpu
Otherwise on the command line run:
pip install tensorflow-gpu
Hope this is helpful to others out there facing issues!
import tensorflow as tf
from transformers import BertTokenizer, TFBertForSequenceClassification
Worked with
Tensorflow-2.7.0
huggingface-hub-0.2.1
tokenizers-0.10.3
transformers-4.15.0
Python-3.7
Install Tensorflow and Transformers
!pip install tensorflow
!pip install transformers
I believe you are on MacOS. If so, installing the latest version of transformers (v4.21.1) should fix this issue. (I am also running M1 pro, if that helps).
For me the latest update was giving an error with incompatible checkpoint weight files, so I had to install transformers v4.2.2 which gave me the above error.
To fix it, you need to do an editable install: https://huggingface.co/docs/transformers/installation#installing-from-source
i.e.
git clone https://github.com/huggingface/transformers.git
cd transformers
pip install -e .
Before running the above code, make the following changes:
In transformers/setup.py Line 134, change to "tokenizers==0.6.0"
In transformers/src/transformers/file_utils.py Line 87, change "tensorflow" to "tensorflow-macos"
Finally, in transformers/src/transformers/dependency_versions_check.py comment out Line 41 ("# require_version_core(deps[pkg])"
For the final step, upgrade the tokenizers library to a newer version (say 0.12.1). You cant have the newer tokenizers library before installing the transformers package - it fails to build the wheel.
Reference: https://id2thomas.medium.com/apple-silicon-experiment-1-installing-huggingface-transformers-2e45392d3d0f
https://github.com/apple/tensorflow_macos/issues/144
Transformers requires Tensorflow version >= 2.3
To see the installed Tensorflow version, run the python script below:
import tensorflow as tf
print(tf.__version__)
If tensorflow version is actually too low, you may upgrade it.
For Tensorflow of CPU version,
run the command in a notebook,
!pip install tensorflow>=2.3
or run the command in a command window:
pip install tensorflow>=2.3
For Tensorflow of GPU version,
run the command in a notebook,
!pip install tensorflow-gpu>=2.3
or run the command in a command window,
pip install tensorflow-gpu>=2.3
I am trying to install waymo open dataset in the windows environment. However when I try I get the following error:
(python3.6) C:\Users\19729>pip install waymo-open-dataset-tf-2-3-0 ERROR: Could not find a version that satisfies the requirement waymo-open-dataset-tf-2-3-0 (from versions: none) ERROR: No matching distribution found for waymo-open-dataset-tf-2-3-0
How to resolve this?
This piece of code does not show any error when I tried this in colab with TensorFlow 2.7.
However you can try again using below code :
pip3 install --upgrade pip
pip3 install waymo-open-dataset-tf-2-6-0 --user # for tf 2.6.0. OR
pip3 install waymo-open-dataset-tf-2-5-0 --user # for tf 2.5.0. OR
pip3 install waymo-open-dataset-tf-2-4-0 --user # for tf 2.4.0.
You can also load this built-in tensorflow dataset from tensorflow_datasets using:
!pip install tensorflow_datasets
import tensorflow_datasets as tfds
from tensorflow_datasets.object_detection import WaymoOpenDataset
ds = tfds.load('waymo_open_dataset', split='train', shuffle_files=True)
Note: This may take some time as it is 336.62 GiB dataset.
There are some waymo_open_datasets also available in Kaggle.
I tried to import keras-vggface like this:
from keras_vggface.vggface import VGGFace
But it always gives me this error
"ModuleNotFoundError: No module named 'keras_vggface".
I tried to install keras_vggface with pip like this:
!pip install --user keras-vggface
!pip install keras-vggface
!pip install git+https://github.com/rcmalli/keras-vggface.git
I think you need to install it as below:
!pip install keras_vggface
this works like a charm.
Hope it can be useful.
Struggling with VGGFace use in colab as well, resolved your problem by specifying in colab tensor flow x1 with %tensorflow_version 1.xas informed by colab warning VGGFace git:
"VGGFAce works only with 1.x TensorFlow backend AND without eager execution!!!"
EDIT: but you have to properly call !pip install keras_vggface first
When I try to install pydot it says that I have already installed it.
But whenever I try to import it I get an error saying :
Failed to import pydot. You must install pydot and graphviz for pydotprint to work.
This is my code:
model.summary()
import pydot
from keras.utils import plot_model
plot_model(model, to_file='model.png')
I am using python 3.6.3 on jupyter notebook.
download the msi version of graphviz from >http://www.graphviz.org/Download_windows.php
add C:\Program Files (x86)\Graphviz2.38\bin to my system variables in PATH