problem in upgrading scikit-image version - python

On my system spyder version '0.13.1' is installed and I want to use
from skimage.filters import unsharp_mask
the error comes:
ImportError: cannot import name 'unsharp_mask
then I treid to upgrade the version using:
1st passed;
!pip install scikit-image
then I passed:
!pip install --upgrade scikit-image
then still version is same which is '0.13.1'.
What should I do?

The problem is resloved with the help of Anaconda official video tutorial :
https://anaconda.cloud/tutorials/getting-started-with-anaconda-individual-edition?source=install

Related

ModuleNotFoundError: No module named 'tensorflow.python.checkpoint'

this is the code. im executing this using spyder. and tried many versions of tensorflow but unable to solve this
this is the error im getting. before i was gettng import error cannot import 'load_img'
I had a similar problem. I had tensorflow 2.6.0 installed but tensorflow-estimator 2.10.0. The problem was solved by downgrading tensorflow-estimator:
pip install --upgrade tensorflow-estimator==2.6.0
Download tensorflow before running your code.
pip install tensorflow

ImportError: cannot import name 'dtensor' from 'tensorflow.compat.v2.experimental'

I'm trying to create object detection using tensorflow as an assignment.
ImportError: cannot import name 'dtensor' from 'tensorflow.compat.v2.experimental' (c:\Project\.venv\lib\site-packages\tensorflow\_api\v2\compat\v2\experimental\__init__.py)
I would appreciate any help!
I got the same error. I downgraded to Keras v2.6.0, which fixed the issue.
Hence, as of 16.05.2022, this seems to be caues by a bug in v2.9.*
To downgrade to v2.6.0, run:
!pip install keras==2.6.*
Please try again by upgrading the TensorFlow version to the latest version 2.9 and restart the kernel(runtime) to fix this issue.
!pip install tensorflow==2.9
#Or
!pip install --quiet --upgrade --pre tensorflow
For example:
import tensorflow as tf
from tensorflow.experimental import dtensor
print('TensorFlow version:', tf.__version__)
mesh_1d = dtensor.create_mesh([('x', 6)])#, devices=DEVICES)
print(mesh_1d)
Output:
TensorFlow version: 2.9.1
<tensorflow.dtensor.python.layout.Mesh object at 0x7f890d7ce690>
Please check this link for more details.

Could not import PILLOW_VERSION from PIL

While importing, Python (Anaconda) gives the following error:
ImportError: cannot import name 'PILLOW_VERSION' from 'PIL'
I tried removing pillow and then conda install but the error persists.
Pillow 7.0.0 removed PILLOW_VERSION, you should use __version__ in your own code instead.
https://pillow.readthedocs.io/en/stable/deprecations.html#pillow-version-constant
Edit (2020-01-16):
If using torchvision, this has been fixed in v0.5.0. To fix:
Require torchvision>=0.5.0
If Pillow was temporarily pinned, remove the pin
Old info (2020-01-09):
If using torchvision, there is a release planned this week (week 2, 2020) to fix it:
https://github.com/pytorch/vision/issues/1712#issuecomment-570286349
The options are:
wait for the new torchvision release
use the master version of torchvision (eg. pip install -U git+https://github.com/pytorch/vision)
install torchvision from a nightly, which also requires a pytorch from a nightly version
or install Pillow<7 (eg. pip install "pillow<7")
Downgrade pillow if you don't need latest features
pip uninstall pillow
pip install "pillow<7"
Or for anaconda,
conda install -c anaconda "pillow<7"
I have solved by modifying functional.py and __init__.py which are mentioned in error message.Error.
Modify from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION to from PIL import Image, ImageOps, ImageEnhance, __version__ in functional.py approx line number 5.
Modify PILLOW_VERSION = __version__ = _version.__version__ to __version__ = __version__ = _version.__version__ in __init__.py, approx line no 22.
File path:
functional.py:C:\Users\UserName\AppData\Local\Programs\Python\Python37\Lib\site-packages\torchvision\transforms\functional.py
__init__.py:C:\Users\UserName\AppData\Local\Programs\Python\Python37\Lib\site-packages\PIL\__init__.py
Currently using torchvision==0.4.2 and this solved my problem.
Downgrade your pillow to 6.1 and restart your Jupyter notebook.
Use this
conda install pillow=6.1
I found one another good solution:
Install Pillow-SIMD instead of Pillow.
Pillow-SIMD is "following" Pillow. Pillow-SIMD versions are 100%
compatible drop-in replacements for Pillow of the same version.
SIMD stands for "single instruction, multiple data" and its essence is
in performing the same operation on multiple data points
simultaneously by using multiple processing elements.
Homepage:
https://github.com/uploadcare/pillow-simd
Benchmarks:
https://python-pillow.org/pillow-perf/
Install instructions:
$ pip uninstall pillow
$ CC="cc -mavx2" pip install -U --force-reinstall pillow-simd
I checked: it has not such error and works on Pytorch/Torchvision.
You don't need to downgrade packages or change source code.
This is my fix to the error
Error: Could not import PILLOW_VERSION from PIL
OS: Linux 18.0 (LUBUNTU)
Python: 3.6
Resolved the issue by downgrading pillow:
pillow: 7.0.0-py36hb39fc2d_0 --> 6.1.0-py36h34e0f95_0
command: conda install pillow=6.1
The less painful way that worked for me is using alias
from PIL import __version__ as PILLOW_VERSION
Why?
Pillow is forked from PIL 1.1.7
VERSION was removed in Pillow 6.0.0
PILLOW_VERSION was removed in Pillow 9.0.0
Use __version__ instead
When you use some older packages, they try to import PILLOW_VERSION which is no longer available. So you'll need to use alias.

openCV Error module 'cv2.face' has no attribute 'createEigenFaceRecognizer'

I am using python 3.7 and latest version of openCV. When i try to create an EigenFaceRecognizer. This error pops up "module 'cv2.face' has no attribute createEigenFaceRecognizer. I have got this bellow code from a Gitub repo.
recognise = cv2.face.createEigenFaceRecognizer(15, 4000)
recognise.load("Recogniser/trainingDataEigan.xml")
I believe the face module is in the opencv-contrib library. You can install it with
pip uninstall opencv-contrib-python
pip install opencv-contrib-python --no-cache-dir
Also the function got changed to this. load was replaced with read
import cv2
recognise = cv2.face.EigenFaceRecognizer_create()
recognise.read("Recogniser/trainingDataEigan.xml")

attributeerror: module 'cv2.face' has no attribute 'createlbphfacerecognizer'

So i'm doing a little personal project but i keep getting this error when I try to create the recognizer. i have opencv-contrib and everything. Does anyone know whats going on? code posted below
import cv2, os
import numpy as np
from PIL import Image
cascadePath = "haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(cascadePath)
recognizer = cv2.face.createLBPHFaceRecognizer()
it gets caught on that last line. I've tried reinstalling all modules already. Not really sure what else to do. The weird thing is it works on my laptop but not my desktop. They both have the same modules, same python release and running the exact same code.
Had the same problem. Use:
recognizer = cv2.face.LBPHFaceRecognizer_create()
It worked for my program.
Under Windows 7, I was able to resolve the issue by simply uninstalling and re-installing opencv:
pip uninstall opencv-contrib-python
pip install opencv-contrib-python
The recogniser is called by:
recognizer = cv2.face.LBPHFaceRecognizer_create()
There are some missing modules for contributed libraries in the default pip install opencv-python so you need pip install opencv-contrib-python
try this it worked for me
pip install --force-reinstall opencv-contrib-python==4.1.2.30
Try to update your opencv by "python -m pip install opencv-contrib-python"
ps: you have to delete the CV2 repository from the Python rep and then run this command (in the CMD windows) if it doesn't work
Try to use this:
import cv2
import os
import numpy as np
from PIL import Image
# Path for face image database
path = 'dataset'
recognizer = cv2.face_LBPHFaceRecognizer.create()
detector = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
I had this problem running opencv Version 3.4.1. Here is what I did.
SPECS:
Raspberry pi 3B, OS: Raspbian, Version: 9 (Stretch), Python 3, opencv Version 3.4.1
Check opencv version in python
import cv2
cv2.__version__
1) sudo pip install opencv-contrib-python
*After this I could not import cv2 in python until I installed the following.
2) sudo apt-get update
3) sudo apt-get install libhdf5-dev
4) sudo apt-get update
5) sudo apt-get install libhdf5-serial-dev libqtgui4 libqt4-test
I fixed this issue with two commands:
First: sudo pip3 uninstall opencv-contrib-python
Second: sudo python3 -m pip install opencv-contrib-python==3.3.0.9
This fixed my issues. Hope it helps somebody!
Also, if you are using python2, replace “pip3” with “pip” and “python3” with “python”
Uninstall this package (opencv-python) by command :-
pip uninstall opencv-python
Install the library opencv-contrib python using command :-
pip install opencv-contrib-python
then add or check :-
recognizer = cv2.face_LBPHFaceRecognizer.create()
It will work fine
The problem was in opencv-python library cv2.face is not present so it shows attribute missing problem, so install new lib by uninstalling previous one if installed..
recognizer = cv2.face_LBPHFaceRecognizer.create()
You are using Opencv 3.x, in the new version few modules has been removed. You have two options:
1. Add opencv_contrib module to your existing opencv 3.x version.
Here's the link https://github.com/opencv/opencv_contrib
2.you can use older versions of Opencv. Like opencv 2.4.x
open cmd , then --> pip install opencv-contrib-python
I fixed this issue by installing:
sudo pip install opencv-contrib-python.
Then look for correct format.
python2 is default
Basically the problem is that python3 and python2 have different format of code.
recognizer = cv2.face.LBPHFaceRecognizer_create()
This is the format of python2.
recognizer = cv2.face.createLBPHFaceRecognizer()
This is the format of python3
Even I had this problem when I ran the code using Jupyter Notebook.
If you are running it on Jupyter Notebook , then download it as pyhton(.py) file and try to run it in Anaconda Prompt or Command Prompt. This solved the problem for me.
Thank You.
Installing opencv-contrib-python solved the issue.
I had installed only opencv-python, After Installing opencv-contrib-python, solved the issue.
pip install opencv-contrib-python
If you are using python3 use pip3 instead of pip:
pip3 install opencv-contrib-python
Then you can simply do:
recognizer = cv2.face.LBPHFaceRecognizer_create()
write
pip install opencv-contrib-python --upgrade
if gives error then
write
pip install opencv-contrib-python --user
it will work fine for cv2.face.LBPHFaceRecognizer_create()
There are some missing modules for contributed libraries in the default pip install opencv-python-contrib so you need pip install opencv-contrib-python --upgrade
This will download a 41.5MB file and install that in your python package folder , after that you can check by simply First "import cv2" then typing "print(dir(cv2.face))" that will return a list of attributes in cv2.face which will include "createlbphfacerecognizer"
I am also facing an same issue after installation of these below command in my command prompt.
> pip install opencv-contrib-python
> pip install opencv-contrib-python --user
Facing this below error in jupyter notebook.
Training done ---------------
--------------------------------------------------------------------------- AttributeError Traceback (most recent call
last) ~\AppData\Local\Temp/ipykernel_4424/3540845204.py in
40 labels = np.array(labels)
41
---> 42 face_recognizer = cv.face.LBPHFaceRecognizer_create()
43
44 # Train the Recognizer on the features list and the labels list
AttributeError: module 'cv2' has no attribute 'face'
After i am tried with visual studio code but make sure your running with this below confirmation commands in your command prompt or terminal.
I will suggest you to try in command prompt.
Microsoft Windows [Version 10.0.19043.1348]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Admin>python
Python 3.10.1 (tags/v3.10.1:2cd268a, Dec 6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> print(cv2.__version__)
4.5.5
>>> **recognizer = cv2.face.LBPHFaceRecognizer_create()**
>>> **print(recognizer)**
**<face_LBPHFaceRecognizer 000001F890F3D8D0>**
>>>
After successfully fixed this issue, i have got these below outputs.
on.exe' 'c:\Users\Admin\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy\launcher'
'55275' '--' 'c:\Users\Admin\Downloads\Opencv\Faces\face.py'
> Training done ---------------
PS C:\Users\Admin\Downloads\Opencv\Faces> c:; cd 'c:\Users\Admin\Downloads\Opencv\Faces'; & 'C:\Program
Files\Python310\pyth0' '--'
'c:\Users\Admin\Downloads\Opencv\Faces\face_recognization1.py'
> Label = Elton John with a confidence of 0.0
> Label = Elton John with a confidence of 0.0
on.exe'
'c:\Users\Admin\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy\launcher'
'55339' '--'
'c:\Users\Admin\Downloads\Opencv\Faces\face_recognization1.py'
> Label = nidhi agarwal with a confidence of 0.0

Categories