Greetings and thank you for this awesome project!
I got the following problem when I installed the dependencies:
error: numpy 1.16.3 is installed but numpy>=1.17 is required by {'matplotlib'}
error: numpy 1.16.3 is installed but numpy>=1.17.3 is required by {'PyWavelets'}
I resolved the problem by changing the dependencies in requirements.txt
:
Then I got this wall of text error when I tried to run inference:
$ python3 homogenus/tf/homogenus_infer.py -h
Traceback (most recent call last):
File "homogenus/tf/homogenus_infer.py", line 21, in <module>
import tensorflow as tf
File "/home/.../source/homogenus/.venv/lib/python3.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/.../source/homogenus/.venv/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/home/.../source/homogenus/.venv/lib/python3.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 15, in <module>
from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2
File "/home/.../source/homogenus/.venv/lib/python3.7/site-packages/tensorflow/core/framework/node_def_pb2.py", line 15, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "/home/.../source/homogenus/.venv/lib/python3.7/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 15, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "/home/.../source/homogenus/.venv/lib/python3.7/site-packages/tensorflow/core/framework/tensor_pb2.py", line 15, in <module>
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File "/home/.../source/homogenus/.venv/lib/python3.7/site-packages/tensorflow/core/framework/resource_handle_pb2.py", line 41, in <module>
serialized_options=None, file=DESCRIPTOR),
File "/home/.../source/homogenus/.venv/lib/python3.7/site-packages/google/protobuf/descriptor.py", line 560, in __new__
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
Then I headed to the link to check what's going on. It looks like this has something to do with tensorflow and protocol buffers. My tf version:
It's not 1.15.2
because I tried this PR.
My protobuf
version:
I have a few options:
- upgrade tensorflow to
2.x
- downgrade
protobuf
to 3.20.x
or lower.
You can see the PRs for changing requirements in this repo. I didn't test them yet. This is what worked for me:
$ pip install protobuf==3.20
Collecting protobuf==3.20
Using cached protobuf-3.20.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.0 MB)
ERROR: homogenus .5 has requirement numpy==1.17.3, but you'll have numpy 1.16.3 which is incompatible.
Installing collected packages: protobuf
Attempting uninstall: protobuf
Found existing installation: protobuf 4.21.2
Uninstalling protobuf-4.21.2:
Successfully uninstalled protobuf-4.21.2
Successfully installed protobuf-3.20.0
Even though I got the warning it worked for me in the end. Test to validate this:
$ python3 homogenus/tf/homogenus_infer.py -h
usage: homogenus_infer.py [-h] [-tm TRAINED_MODEL_DIR] -ii IMAGES_INDIR -oi
OPENPOSE_INDIR [-io IMAGES_OUTDIR]
[-oo OPENPOSE_OUTDIR]
optional arguments:
-h, --help show this help message and exit
-tm TRAINED_MODEL_DIR, --trained_model_dir TRAINED_MODEL_DIR
The path to the directory holding homogenus trained
models in TF.
-ii IMAGES_INDIR, --images_indir IMAGES_INDIR
Directory of the input images.
-oi OPENPOSE_INDIR, --openpose_indir OPENPOSE_INDIR
Directory of openpose keypoints, e.g. json files.
-io IMAGES_OUTDIR, --images_outdir IMAGES_OUTDIR
Directory to put predicted gender overlays. If not
given, wont produce any overlays.
-oo OPENPOSE_OUTDIR, --openpose_outdir OPENPOSE_OUTDIR
Directory to put the openpose gendered keypoints. If
not given, it will augment the original openpose json
files.
Just for convenience, here's my setup.
I used venv, but you can do similar with conda if that rocks your boat.
python3.7 -m venv .venv
source .venv/bin/activate
$ pip freeze
absl-py==1.1.0
astor==0.8.1
cycler==0.11.0
fonttools==4.34.4
gast==0.2.2
google-pasta==0.2.0
grpcio==1.47.0
h5py==3.7.0
homogenus===.5
imageio==2.5.0
importlib-metadata==4.12.0
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.2
kiwisolver==1.4.3
Markdown==3.3.7
matplotlib==3.5.2
mock==4.0.3
networkx==2.6.3
numpy==1.16.3
opt-einsum==3.3.0
packaging==21.3
Pillow==9.2.0
protobuf==3.20.0
pyparsing==3.0.9
python-dateutil==2.8.2
PyWavelets==1.3.0
scikit-image==0.15.0
scikit-learn==0.20.3
scipy==1.2.1
six==1.16.0
tensorboard==1.13.1
tensorflow==1.13.1
tensorflow-estimator==1.13.0
termcolor==1.1.0
typing_extensions==4.3.0
Werkzeug==2.1.2
wrapt==1.14.1
zipp==3.8.1
You could do the same with different tensorflow versions: just downgrade protobuf
and hope for the best. I hope this helps someone else and saves them the 30 minutes I used for this :)