I am trying to use caffe module with OpenCV. I am creating environment using Anaconda. I am not finding this module in Anaconda. Tried conda install caffe, it didn't work.
I am new to OpenCV and Python, please guide or provide reference on how to install caffe.
Please see the official install documentation directly on Caffe's site. You need to compile Caffe itself, and then compile the Python wrappers.
Related
I am a beginner in terms of using python. Currently, I got python 3.7 and I am using anaconda as IDE. For my project, I need to detect the location and brightness of points/dots in an external imported picture. I figure I could use the modul OpenCV. Unfortunately, I am stuck right now with the problem to import the module cv2. I already successfully installed the package using
python -m pip install OpenCV-python
on command prompt. OpenCV Version which was installed is 4.2.0.34. While compiling the test script of OpenCV on Spyder
import cv2
print(cv2.__version__)
I got this message
"ImportError : DLL load failed : The Modul was not found."
Can somebody let me know please how to fix this problem? Is somehow the version of OpenCV I got not compatible with the Python version? I already watched and followed many tutorial videos on Youtube, but I couldn't find the solution. I tried to copy the cv2.pyd to the site-packages folder in
C:/user/Anaconda3/Lib/site-packages directory
still it didn't fix the problem...
I would appreciate any answers and help I could get here. Thank you!
try installing it using these commands in the following order:
conda update anaconda-navigator
conda update navigator-updater
pip install opencv-python
It should work fine.
Try conda install opencv
or conda install -c menpo opencv
I started learning machine learning. I was stuck in the IDE where I was unable to add the module of sklearn in my Python file. It was showing ModuleNotFoundError: No module named 'sklearn.cross_validation'
Refer to this link on guide on how to install libraries in Spyder. If you are on ubuntu, then the best thing for you would be to install packages using pip as that will install and settle dependencies. You can also use conda for that. Make sure that python environment that spyder is using is same as the python environment you are installing the package for.
Great that you started learning machine learning, enjoy the journey!
I would advise you to install python using Anaconda https://www.anaconda.com/distribution/
If you do this most of the modules you will need will be pre-installed.
I am creating a face recognition system using Python and OpenCV on these versions:
Python 3.6.2 :: Anaconda custom (64-bit)
Anaconda 4.3.23
OpenCV 3.3.0
When I try to train the face recognizer:
face_recognizer = cv2.face.createLBPHFaceRecognizer()
I get this error:
AttributeError: module 'cv2' has no attribute 'face'
Update:
I've tried to do this:
pip install opencv_python‑3.3.0+contrib‑cp36‑cp36m‑win_amd64.whl
Also:
conda install -c menpo opencv3=3.3.0
And I still have the error.
The Menpo project does not have an installer for OpenCV 3.3. The Menpo project is up to 3.1 on macOS and Windows, and 3.2 on Linux. See the Anaconda package for that description and also the list of files for the installer versions. Actually, you can check out the GitHub repo for Menpo's OpenCV3 build and grab the files yourself. You can change the build files to suit your system if needed.
I'm not sure if your pip attempt includes a typo or not---the correct PyPI package wheel file with the contrib module is opencv_contrib_python not opencv_python+contrib, as shown at PyPI. Note that if you're not using Windows the GUI features of OpenCV will not work with the pip installer, including imshow() and other similar features.
You'd be better served just removing and reinstalling fresh with the contrib modules instead of trying to build them in later.
While I was looking for the same solution, I tried out many methods which don't work well with successfully installing OpenCV along with the extra modules i.e., OpenCV Contrib.
Apparently, while using pip install opencv-python windows platforms usually download only OpenCV without the extra modules!
What works, is stable and easy to install:
Download the integrated 'whl' file containing both OpenCV and it's Contrib files, which would be like 'opencv_python‑3.4.3+contrib‑cp36‑cp36m‑win_amd64.whl' which can be downloaded from here.
Install using pip install <whl filename>
I have tried other methods which are unreliable such as the solution suggested by #RoyaumeIX, however ended up with failure.
So is it with using
pip install opencv
pip install opencv-contrib
Installing opencv-contrib does not properly register the opencv package.
I strongly suggest that you directly download the official whl file and install it.
I also had same problem but it got resolved by following these steps:
start anaconda navigator
open CMD.exe prompt, hope you see this **(base) C:\Users\acer>** this may be different for you
write these command >>>**pip install opencv-contrib-python**
Now you can run your code as check!! I have runned my code in Spyder in base enviroment and it worked for me!
my using python 2.7 and opencv 3.3.0
working in code
cv2.face.LBPHFaceRecognizer_create();
Solution, as were found at OpenCV forum (and same at StackOverflow), works well for me:
pip install opencv-python
pip install opencv_contrib_python
And in cv2 version 4.0.0 face recogniser can be created by using different function name, as mentionted above:
face_recognizer = cv2.face.LBPHFaceRecognizer_create()
face_recognizer = cv2.face.EigenFaceRecognizer_create()
face_recognizer = cv2.face.FisherFaceRecognizer_create()
this should fix the problem
pip install opencv-python-headless
pip install opencv-contrib-python-headless
I found the solution to my issue, you have to follow this tutorial OpenCV with extra modules.
The essential steps are:
Go to C:/PythonXX/lib/site-packeges (the site-packages folder where your python is installed), and delete cv2.pyd if present.
Download OpenCV with extra modules
Create a Visual Studio project with CMake
Open Python IDLE and enter import cv2. If there is no error, then the installation is successful.
I tried to install GraphLab, but the result became like this:
AttributeError: module 'graphlab' has no attribute 'connect'
My python version is 3.6.1. And I also tried the code:
python -m pip install connect
But it didn't work.
Does anyone know how to solve this problems? Thanks!
This happens when Version in python on system is different from Anaconda. Anaconda Python is mixing in imports from the regular Python on the system. Make sure "which python" points to the right Python (whereever you installed Anaconda Python. And similarly "which pip" Otherwise you will want to run python (or pip) from [where ever you installed Anaconda]/bin/python. You can try the Dato Launcher which tries to set it all up for you.
Also, if you are not using Anaconda, on Graphlab support of installation, they recommended only two option for installation, one on Anaconda and the other on Virtualenv. I personally recommend you to use Anaconda for Graphlab as most of the development support and learning is totally based on Anaconda usage. You may follow this link to install Graphlab and Anaconda Here. I hope this helps.
Note: In installation of Anaconda, Python Version can be different like Python 2.7, but after installation of Anaconda, you can update to latest version of your choice.
I have keras installed on my linux machine, but when I try to import a dataset from the keras.datasets I get an error that it cannot find it.
So for example:
from keras.datasets import mnist
I get the error
ImportError: No module named keras.datasets
I installed keras using pip install and it installed successfully.
Indeed the problem was that I had multiple versions of Python.
Removing Anaconda Python and installing all libraries using pip / apt-get instead of conda solved my problem.
I found this to be true but it is not necessary to delete anaconda.
I had the same issue but with multiple python versions. However, i created an environment that only used the Anaconda version (while in that environment). In terminal (on mac and other suitable terminals), type/copy
conda create -n dataweekends python=2.7 pandas scikit-learn jupyter matplotlib
dataweekends is simply the name of the environment you created. To access this, just use the command
source activate dataweekends
Be mindful that you might (probably) have to reinstall dependencies once in that new environment.
I got this trick from here "https://www.dataweekends.com/blog/2017/03/09/set-up-your-mac-for-deep-learning-with-python-keras-and-tensorflow"
I would also recommend setting up different environments for each project you do in python.
Do you have keras.py or keras.pyc in the current working directory? If so, this will mess up the imports. Try renaming the file and/or deleting keras.pyc.
Thanks to the comment from Selcuk which got me on the right track.
Indeed the problem was that I had multiple versions of Python.
I followed some online instructions to installing Keras which recommended installing MiniConda/Conda/Anaconda which is its own version of python. So I had two Python2.7 versions installed:
Normal Linux Python 2.7
Anaconda Python 2.7
Removing Anaconda Python and installing all libraries using pip / apt-get instead of conda solved my problem.