PsychoinformaticsLab / pliers

Automated feature extraction in Python
https://pliers.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
296 stars 68 forks source link

clarifai deprecation ; clarifai-grpc support ? #469

Closed emdupre closed 2 years ago

emdupre commented 2 years ago

Hi everyone,

Thanks for making such a great package !

I'm running pliers on a series of videos, and I'd like to include the ClarifaiAPIImageExtractor transformer. I get a KeyError, though, when running the transformer if the python package clarifai is in my conda environment.

Looking at the clarifai docs, I realized that this package has actually been deprecated in favor of clarifai-grpc. It seems from the dependencies, though, that pliers is still using the original, now deprecated version of the clarifai API.

Is this something that could be updated ?

pliers version : 0.4.1 full pip freeze (with the current clarifai-grpc) :

``` asttokens @ file:///opt/conda/conda-bld/asttokens_1646925590279/work backcall @ file:///home/ktietz/src/ci/backcall_1611930011877/work cachetools==5.2.0 certifi @ file:///opt/conda/conda-bld/certifi_1655968806487/work/certifi charset-normalizer==2.1.1 clarifai-grpc==8.8.0 click==8.1.3 configparser==3.8.1 decorator==4.4.2 executing @ file:///opt/conda/conda-bld/executing_1646925071911/work face-recognition-models==0.3.0 flatbuffers==1.12 future==0.18.2 google-api-core==2.8.2 google-api-python-client==2.58.0 google-auth==2.11.0 google-auth-httplib2==0.1.0 googleapis-common-protos==1.56.4 grpcio==1.47.0 httplib2==0.20.4 idna==3.3 imageio==2.21.2 imageio-ffmpeg==0.4.7 ipython @ file:///opt/conda/conda-bld/ipython_1657652213665/work jedi @ file:///tmp/build/80754af9/jedi_1644297102865/work joblib==1.1.0 jsonschema==2.6.0 keras==2.9.0 libclang==14.0.1 matplotlib-inline @ file:///tmp/build/80754af9/matplotlib-inline_1628242447089/work moviepy==1.0.3 murmurhash==1.0.7 nltk==3.7 numpy==1.23.2 pandas==1.4.3 parso @ file:///opt/conda/conda-bld/parso_1641458642106/work pexpect @ file:///tmp/build/80754af9/pexpect_1605563209008/work pickleshare @ file:///tmp/build/80754af9/pickleshare_1606932040724/work Pillow==9.2.0 pliers==0.4.1 proglog==0.1.10 prompt-toolkit @ file:///tmp/build/80754af9/prompt-toolkit_1633440160888/work protobuf==3.19.3 ptyprocess @ file:///tmp/build/80754af9/ptyprocess_1609355006118/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl pure-eval @ file:///opt/conda/conda-bld/pure_eval_1646925070566/work pyasn1==0.4.8 pyasn1-modules==0.2.8 Pygments @ file:///opt/conda/conda-bld/pygments_1644249106324/work pyparsing==3.0.9 python-dateutil==2.8.2 python-magic==0.4.27 pytz==2022.1 regex==2022.8.17 requests==2.28.1 rsa==4.9 scipy==1.9.1 six @ file:///tmp/build/80754af9/six_1644875935023/work SpeechRecognition==3.8.1 stack-data @ file:///opt/conda/conda-bld/stack_data_1646927590127/work tensorboard-plugin-wit==1.8.1 termcolor==1.1.0 tokenizers==0.12.1 tqdm==4.64.0 traitlets @ file:///tmp/build/80754af9/traitlets_1636710298902/work uritemplate==4.1.1 urllib3==1.26.12 wasabi==0.9.1 wcwidth @ file:///Users/ktietz/demo/mc3/conda-bld/wcwidth_1629357192024/work ```
emdupre commented 2 years ago

Note that, unfortunately, it doesn't seem to be a simple substitution -- I believe several of the internal calls will need to be updated as well. Happy to help with that, if this is of interest !

qmac commented 2 years ago

I can look into this over the weekend/next week, if nobody is already!

adelavega commented 2 years ago

Hi @emdupre, unfortunately all of the API based decoders are moving targets that are always a pain to stay on top of. Unlike a local algorithm which you can pin, the APIs become unusable.

@qmac thanks for the help! that's awesome. please let me know how that goes, and I can try to help as well.

I would also suggest that you look into local based models, as those have improved substantially. I actually haven't had the time to look at this enough, but they would fall under TFHubExtractor which allows you to access any extractor from TensorFlow Hub.

One example is this model: https://tfhub.dev/google/faster_rcnn/openimages_v4/inception_resnet_v2/1

That said, I haven't tired this myself, and it could take some work. I'll try to set aside some time to play with this soon! Please, prod me if I don't.

emdupre commented 2 years ago

Thank you both !

I am definitely planning on working with additional, locally-deployed models, but for the moment I'm still trying to use up the trial credits I have across a few API providers 😸

That said, I just opened another issue (#473 ) on changes to the Google APIs that seem to also be impacting functionality. So I certainly understand that all of these endpoints are a moving target ! Please let me know how I can help, here.

adelavega commented 2 years ago

I'm happy to try to fix these, and if it's a huge problem to we can make the call to deprecate then.

adelavega commented 2 years ago

Okay good news! I was able to get the ClarifaiImageExtractor to work with the clarifai-grpc library.

I'll open a PR with a (broken) implementation, as I need to convert their outputs to pliers internals.

But it shouldn't be too bad because the hardest part is done: actually authenticating and making a valid request.