mowshon / age-and-gender

Predict Age and Gender of people from images | Determination of gender and age
https://python-scripts.com
MIT License
103 stars 18 forks source link

Install failed: ModuleNotFoundError: No module named 'age_and_gender' #4

Open Nomia opened 3 years ago

Nomia commented 3 years ago

Here is a simple colab installation steps to reproduce(just run all cells): https://colab.research.google.com/drive/1qIO7nJinqQpZuL3Hp7jB-iI6XD3jSzBr?usp=sharing

Failed at last step: image

lawleenaja commented 1 year ago

There is probably some path variable that you can set up.. but a simple workaround is to run the following command on colab

%cd /content/age-and-gender !cp -r /root/.local/lib/python3.8/site-packages/age_and_gender-1.0.1-py3.8-linux-x86_64.egg/* .

you will have to find out where to copy from based upon the output of the age_and_gender build step... for example...

creating /root/.local/lib/python3.8/site-packages/age_and_gender-1.0.1-py3.8-linux-x86_64.egg Extracting age_and_gender-1.0.1-py3.8-linux-x86_64.egg to /root/.local/lib/python3.8/site-packages

afterwards... results are as follows:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv %cd /content/age-and-gender from age_and_gender import AgeAndGender from PIL import Image

data = AgeAndGender() data.load_shape_predictor('/content/dlib-models/shape_predictor_5_face_landmarks.dat') data.load_dnn_gender_classifier('/content/dlib-models/gender-classifier/dnn_gender_classifier_v1.dat') data.load_dnn_age_predictor('/content/dlib-models/age-predictor/dnn_age_predictor_v1.dat')

image = Image.open('/content/age-and-gender/example/test-image.jpg').convert("RGB") result = data.predict(image)

print(result) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [{'gender': {'value': 'female', 'confidence': 100}, 'age': {'value': 26, 'confidence': 95}, 'face': [419, 266, 506, 352]}, {'gender': {'value': 'male', 'confidence': 99}, 'age': {'value': 60, 'confidence': 74}, 'face': [780, 112, 883, 215]}, {'gender': {'value': 'male', 'confidence': 99}, 'age': {'value': 19, 'confidence': 73}, 'face': [595, 135, 699, 238]}, {'gender': {'value': 'female', 'confidence': 99}, 'age': {'value': 62, 'confidence': 61}, 'face': [227, 198, 314, 285]}, {'gender': {'value': 'female', 'confidence': 100}, 'age': {'value': 24, 'confidence': 66}, 'face': [352, 544, 438, 630]}] result