The Keras implementation of MNIST CNN shown here shows the following error:
TypeError: softmax() got an unexpected keyword argument 'axis'
I spent a long time trying to fix it but nothing works. I am running TensorFlow 1.1.0 and Keras 2.1.6. Thank you for help
You need to use this command to update the version of TensorFlow.
pip install --upgrade tensorflow # for Python 2.7
pip3 install --upgrade tensorflow # for Python 3.n
Your TensorFlow version is too old, you need to upgrade, preferrably to the latest version (currently 1.8).
Related
Trying to install Scipy latest version (1.9.3) on python3.8-alpine image
tiangolo/uwsgi-nginx-flask:python3.8-alpine
is not successful.
Scipy tries to install numpy 1.8.5 and it fails with following error.
ImportError: cannot import name 'Log' from 'distutils.log' (/tmp/pip-build-env-28q9f6x4/overlay/lib/python3.8/site-packages/setuptools/_distutils/log.py)
I can goahead and install lower version of scipy. But I am having issue with Sklearn
While trying to install sklearn, it tries to install latest scipy and it fails.
Is there a way i can enforce scipy version to be installed for sklearn
I had the same problem with alpine and python.
This article shows that alpine images should not be used with python as it:
Make your builds much slower.
Make your images bigger.
On occassion, introduce obscure runtime bugs.
I think that your problem comes from the fact that alpine image does not handle wheels files properly.
I would recommend you to switch from python:3.8-alpine to python:3.8-slim.
The problem comes from setuptools. Pin to a version less than 65. Scipy should build on Alpine from source without issue. One of the scipy continuous integration tests checks this. https://github.com/scipy/scipy/blob/main/ci/cirrus_general_ci.yml#L40.
I am trying to run my python code which uses tensorflow-federated on a GPU. To set up my environment, I use venv. First, I install tensorflow-gpu, and my python code then can recognize the GPU, I use tf.test.gpu_device_name(). However, as soon as I install tensorflow-fedenerated, my python stops seeing any GPU and starts using CPUs!!
I am using Ubuntu 16.04.6 LTS. I tried a plenty of combinations of different versions of the packages:
python = 3.6, 3.7
cuda = 10.0, 10.1
tensorflow-gpu = 1.13.1, 1.15, 2.1.0, 2.0.0-alpha0
tensorflow-fedenerated = 0.2.0, 0.12.0, 0.13.0
It's hard to say exactly what the problem is here, but I do have a suspicion.
TFF declares TensorFlow 2.1 as a required package; this may mean that your TF-gpu installation is being removed during the TFF installation setup.
Can you please try the following order:
Open a fresh venv
Install TFF
Uninstall TF
Install TF GPU 2.1.0
I have previously installed python 3.7, anaconda3 and jupyter notebook.
Then I tried to install opencv library using the following command.
pip install opencv-python
and it said,
Requirement already satisfied: opencv-python in c:\programdata\anaconda3\lib\site-packages (4.1.1.26)
When I tried to import open-cv library from IDLE it gives the following error.
ModuleNotFoundError: No module named 'cv2'.
But when I run it from the jupyter notebook it works.
The reason for this as I see is that the packages are installed in the anaconda3 folders but not in the python folders.
How can I install packages in python folders? As I need to run this from the IDLE.
I'm using python 3.7.1 on windows 10.
Thank you.
what IDLE are u using for program in python? If you are using Python IDLE, usually when you import packages, are installed in C:\Users\Your_Username\AppData\Local\Programs\Python\Python37-32\Lib
If you want to install a package in other folder, try to use this
pip install --target=C:\path\to\folder\ opencv-python
If you have another IDLE, put me in the comments what is it (PyCharm, VSCode...).
I am currently trying to set up the opencv trackers on a Raspberry Pi. However, when I use the MultiTracker_create() function, it gives me an Attribution Error:
multiTracker = cv2.MultiTracker_create()
AttributeError: module 'cv2.cv2' has no attribute 'MultiTracker_create'
The same code works on my computer, but when I try it on the Pi, it experiences the above error. I am currently using Python 3.5 on the Raspi with OpenCV 3.4.4. My computer uses Python 3.7 with OpenCV 3.4.1.
Thank you in advance for your help.
I have made sure that I am using the correct package:
pip3 install opencv_contrib_python
I have also tried to look through the help(cv2) and could not find anything specific about the MultiTracker.
Just stumbled upon this myself. It appears that MultiTracker is no longer part of OpenCV 4.5.1, but you should be able to get it from the legacy package like this:
multiTracker = cv2.legacy.MultiTracker_create()
See https://docs.opencv.org/4.5.1/df/d4a/classcv_1_1legacy_1_1MultiTracker.html
Note that if you subsequently call multiTracker.add(...), you'll need to add the legacy version(s) of the trackers as well.
I've met the same problem and solved it. Maybe you can firstly do pip uninstall opecv-python and pip uninstall opencv-contrib-python, and then do pip install opencv-python==3.4.4.19 and pip install opencv-contrib-python==3.4.4.19. That's my solution, hope it's helpful.
This is an old thread, but I will add my answer, maybe helpful for someone facing same problem.
cv2.MultiTracker_create() is missing from OpenCV documentation also on 4.5.1.
[https://docs.opencv.org/4.5.1/d8/d77/classcv_1_1MultiTracker.html]
OpenCV contrib modules are known to be "unstable" which means that they can break or change. In my case, I had opencv-python and opencv-contrib-python both 4.5.2, but cv2.legacy.MultiTracker_create() was giving error.
Best solution is to uninstall opecv-python and opencv-contrib-python and reinstall version 4.4.0.46.
This will solve the problem.
pip install opencv-python==4.4.0.46
pip install opencv-contrib-python==4.4.0.46
So I am trying to use:
sift = cv2.xfeatures2d.SIFT_create()
and it is coming up with this error:
cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv_contrib\modules\xfeatures2d\src\sift.cpp:1207: error: (-213:The function/feature is not implemented)
This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake
option and rebuild the library in function 'cv::xfeatures2d::SIFT::create'
I am using Python 3.5.0 and opencv(3.4.3) and I am just using idle. This occured after I tried to install TensorFlow and I have tried looking around and have installed opencv-contrib-python but I am still getting the same error. Thank you in advance and I apologise if I have not included enough info
I had the same problem. It seems that SIRF and SURF are no longer available in opencv > 3.4.2.16. I chose an older opencv-python and opencv-contrib-python versions and solved this problem. Here is the history version about opencv-python, and I use the following code :
pip install opencv-python==3.4.2.16
pip install opencv-contrib-python==3.4.2.16
Edit
For Anaconda User just this instead of pip
conda install -c menpo opencv
this will install cv2 3.4.1 and everything you need to run SIFT
Since SIFT patent expired, SIFT has been moved to the main repo.
To use SIFT in Opencv, You should use cv2.SIFT_create() instead of cv2.xfeatures2d.SIFT_create() now. (xfeatures2d only exists in the contrib package, but sift is part of the main package now.)
Below link will be helpful.
https://github.com/opencv/opencv/issues/16736
Edit: The opencv-contrib-python-nonfree was removed from pypi.
On Linux/ MacOS, I've found a better solution! To access nonfree detectors use:
pip install opencv-contrib-python-nonfree
It may be due to a mismatch of opencv version and opencv-contrib version.
If you installed opencv from the source using CMake, and the source version is different from the version of opencv-contrib-python, uninstall the current opencv-contrib-python and do pip install opencv-contrib-python==<version of the source>.X or an another compatible version.
One version setup that I have running is opencv source (3.2), opencv-python (3.4.0.14) and opencv-contrib-python (3.4.2.17)