pliers
pliers copied to clipboard
Unable to run examples
Hi,
I was trying to install and run examples on my machine, but encountered this error. I used pip3 to install.
- Platform: aarch64-apple-darwin20 (64-bit)
- Running under: macOS Monterey 12.4
---------------------------------------------------------------------------
MissingDependencyError Traceback (most recent call last)
Input In [2], in <cell line: 7>()
4 image = join(get_test_data_path(), 'image', 'obama.jpg')
6 # Initialize Extractor
----> 7 ext = FaceRecognitionFaceLocationsExtractor()
9 # Apply Extractor to image
10 result = ext.transform(image)
File ~/Library/r-rpymat/miniconda/envs/rpymat-conda-env/lib/python3.8/site-packages/pliers/extractors/image.py:111, in FaceRecognitionFeatureExtractor.__init__(self, **face_recognition_kwargs)
110 def __init__(self, **face_recognition_kwargs):
--> 111 verify_dependencies(['face_recognition'])
113 self.face_recognition_kwargs = face_recognition_kwargs
114 func = getattr(face_recognition.api, self._feature)
File ~/Library/r-rpymat/miniconda/envs/rpymat-conda-env/lib/python3.8/site-packages/pliers/utils/base.py:124, in verify_dependencies(dependencies)
122 missing.append(module_names[dep].package)
123 if missing:
--> 124 raise MissingDependencyError(missing)
MissingDependencyError:
face_recognition required to use this transformer, but could not be
successfully imported. Please make sure they are installed.
Hi @dipterix !
Hopefully you were able to solve this issue for your use case ! As I just ran into the same issue myself, I wanted to note my solution.
In a miniconda environment, I was able to install face_recognition by running:
conda install -c conda-forge dlib
pip install face_recognition
In the conda environment in which I had already installed pliers. The pip installation for the supporting library dlib has a broken wheel (details included below), so this needs to be separately, correctly installed before the face_recognition package can be added. HTH !
Building wheel for dlib (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [8 lines of output]
running bdist_wheel
running build
running build_py
package init file 'tools/python/dlib/__init__.py' not found (or not a regular file)
running build_ext
ERROR: CMake must be installed to build dlib
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for dlib
Thanks for the help @emdupre! dlib is a bit of a heavy requirement and occasionally has issues.
I will check dlib's repo to see if this issue has been spotted there.
Oh: This is potentially a macos specific issue. I just tried installing dlib on Ubuntu 22.04 and it worked fine. My guess is that OSX does not ship with CMake, and therefore you can't build the wheel.
hello!
I encountered a similar issue with both RMSExtractor (requires librosa) and FaceRecognitionFaceLocationsExtractor (requires face_recognition). (I also encountered the broken wheel issue mentioned above). I managed to install librosa and face_recognition (used @emdupre's solution, thx!) and can import them successfully. But the errors remain the same
for RMSExtractor
---------------------------------------------------------------------------
MissingDependencyError Traceback (most recent call last)
Cell In [12], line 3
1 # Set up Extractor and Converter
2 conv = VideoToAudioConverter()
----> 3 ext = RMSExtractor()
5 # Transform Video to Audio
6 audio_only = conv.transform(test)
File ~/miniconda3/envs/multimodal/lib/python3.10/site-packages/pliers/extractors/audio.py:157, in LibrosaFeatureExtractor.__init__(self, feature, hop_length, **librosa_kwargs)
156 def __init__(self, feature=None, hop_length=512, **librosa_kwargs):
--> 157 verify_dependencies(['librosa'])
158 if feature:
159 self._feature = feature
File ~/miniconda3/envs/multimodal/lib/python3.10/site-packages/pliers/utils/base.py:125, in verify_dependencies(dependencies)
123 missing.append(module_names[dep].package)
124 if missing:
--> 125 raise MissingDependencyError(missing)
MissingDependencyError:
librosa required to use this transformer, but could not be
successfully imported. Please make sure they are installed.
and FaceRecognitionFaceLocationsExtractor
---------------------------------------------------------------------------
MissingDependencyError Traceback (most recent call last)
Cell In [19], line 2
1 # Using the more accurate 'cnn' model, change this to 'hog' for faster perfomance
----> 2 face_ext = FaceRecognitionFaceLocationsExtractor(model='cnn')
4 # This extractor expects ImageStim as input
5 face_ext._input_type
File ~/miniconda3/envs/multimodal/lib/python3.10/site-packages/pliers/extractors/image.py:111, in FaceRecognitionFeatureExtractor.__init__(self, **face_recognition_kwargs)
110 def __init__(self, **face_recognition_kwargs):
--> 111 verify_dependencies(['face_recognition'])
113 self.face_recognition_kwargs = face_recognition_kwargs
114 func = getattr(face_recognition.api, self._feature)
File ~/miniconda3/envs/multimodal/lib/python3.10/site-packages/pliers/utils/base.py:125, in verify_dependencies(dependencies)
123 missing.append(module_names[dep].package)
124 if missing:
--> 125 raise MissingDependencyError(missing)
MissingDependencyError:
face_recognition required to use this transformer, but could not be
successfully imported. Please make sure they are installed.
I used miniconda, MacOS Monterey, tried both python 3.7 and 3.10.
Thanks for the help in advance!
Can you try the following:
from pliers.utils import attempt_to_import
librosa = attempt_to_import('librosa')
What is the variable librosa set to? It should say something like:
<module 'librosa' from '/home/zorro/anaconda3/lib/python3.9/site-packages/librosa/__init__.py'>
It's hard for me to imagine a scenario outside of librosa not being probably installed, as pliers simply tries to import and if it can't it throws an error.
hello, I did
from pliers.utils import attempt_to_import
librosa = attempt_to_import('librosa')
face_recognition = attempt_to_import('face_recognition')
and got
<module 'librosa' from '/Users/yibeichen/miniconda3/envs/pliers/lib/python3.10/site-packages/librosa/__init__.py'>
<module 'face_recognition' from '/Users/yibeichen/miniconda3/envs/pliers/lib/python3.10/site-packages/face_recognition/__init__.py'>
seems reasonable. Then I got different errors for
from pliers.stimuli import AudioStim
from pliers.extractors import RMSExtractor
stim = AudioStim(test2)
ext = RMSExtractor()
rms_features = ext.transform(stim)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File ~/miniconda3/envs/pliers/lib/python3.10/site-packages/pliers/extractors/base.py:19, in Extractor.transform(self, stim, *args, **kwargs)
18 def transform(self, stim, *args, **kwargs):
---> 19 result = super().transform(stim, *args, **kwargs)
20 return list(result) if isgenerator(result) else result
File ~/miniconda3/envs/pliers/lib/python3.10/site-packages/pliers/transformers/base.py:56, in Transformer._memoize.<locals>.wrapper(self, stim, *args, **kwargs)
54 if key in _cache:
55 return _cache[key]
---> 56 result = transform(self, stim, *args, **kwargs)
57 if use_cache:
58 if isgenerator(result):
File ~/miniconda3/envs/pliers/lib/python3.10/site-packages/pliers/transformers/base.py:129, in Transformer.transform(self, stims, validation, *args, **kwargs)
127 return self.transform(validated_stim, *args, **kwargs)
128 else:
--> 129 result = self._transform(validated_stim, *args, **kwargs)
130 result = _log_transformation(validated_stim, result, self)
131 if isgenerator(result):
...
171 elif self._feature == 'tonnetz':
172 return getattr(librosa.feature, self._feature)(
173 y=stim.data, sr=stim.sampling_rate, **self.librosa_kwargs)
AttributeError: 'NoneType' object has no attribute 'feature'
for
face_ext = FaceRecognitionFaceLocationsExtractor(model='cnn')
got
File ~/miniconda3/envs/pliers/lib/python3.10/site-packages/pliers/extractors/image.py:114, in FaceRecognitionFeatureExtractor.__init__(self, **face_recognition_kwargs)
111 verify_dependencies(['face_recognition'])
113 self.face_recognition_kwargs = face_recognition_kwargs
--> 114 func = getattr(face_recognition.api, self._feature)
115 self.func = partial(func, **face_recognition_kwargs)
117 super().__init__()
AttributeError: 'NoneType' object has no attribute 'api'
Strange. This indicates that we can import those libraries, but for whatever attempt_to_import is failing to import inside of pliers. It's returning None which is what happens when it can't load (even though when you do it yourself, it loads fine), and because you loaded it in the same session and it is in the environment verify_dependencies passes.
The only thing I can't think of is that this is a Python 3.10 issue, since I'm running 3.9
I'm working on fixing CI tests here; https://github.com/PsychoinformaticsLab/pliers/pull/486 Will also expand to Python 3.10 to see if that's the issue
hello, I just created a python=3.9 conda env and ran into the same issues I've had above. hmmm, maybe something wrong with my MacOS?
I remember that earlier this year, I successfully used pliers following this notebook to get a transcript from an audio. Maybe I was working on a linux machine by that time... I can't recall.
It is very unusual, and possible something is strange w/ your path such that it's not loading libraries correctly.
There is a docker image available if you want to try that instead: https://github.com/PsychoinformaticsLab/pliers/pkgs/container/pliers
yes! this docker image works! Thanks a lot!