Giter Site home page Giter Site logo

nghorbani / homogenus Goto Github PK

View Code? Open in Web Editor NEW
113.0 8.0 25.0 4.24 MB

Human Image Gender Classifier for Expressive Body Capture

Home Page: https://smpl-x.is.tue.mpg.de/

License: Other

Python 100.00%
machine-learning human gender-classification openpose smpl-x

homogenus's Issues

Problems in installing and running [SOLUTION]

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:

numpy==1.17.3

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:

1.13.1

It's not 1.15.2 because I tried this PR.

My protobuf version:

4.21.2

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.

  • Ubuntu 20.04
  • Python 3.7

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 :)

Prediction label

Excuse me. Can you tell me whether I can change the output of male/ female/ neutral into male/ female? Thanks.

pretrained weights

i followed all the instructions but got an error that i could not resolve
File "/home/wise/testing/homogenus/homogenus/tf/homogenus_infer.py", line 174, in
hg = Homogenus_infer(trained_model_dir=ps.trained_model_dir)
File "/home/wise/testing/homogenus/homogenus/tf/homogenus_infer.py", line 47, in init
self.model = tf.keras.models.load_model(self.best_model_fname)
File "/home/wise/testing/myenv/lib/python3.10/site-packages/keras/src/saving/saving_api.py", line 262, in load_model
return legacy_sm_saving_lib.load_model(
File "/home/wise/testing/myenv/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/home/wise/testing/myenv/lib/python3.10/site-packages/keras/src/saving/legacy/save.py", line 234, in load_model
raise IOError(
OSError: No file or directory found at ./homogenus/trained_models/tf/TR02_E02_It_002010.ckpt
(myenv) wise@wise-Victus-by-HP-Gaming-Laptop-15-fb0xxx:~/testing/homogenus$

i downloaed the weights but i only have the .index , .meta and .00104.0014

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.