Open LC9 opened 6 years ago
Failed in capturing an image from the webcam. https://github.com/yu4u/age-gender-estimation/blob/master/demo.py#L57
The webcam may not be recognized from the virtual machine. Did you allow the virtual machine to used the webcam (as a USB device?) ?
I don’t think so, but my webcam is built-in. Do you know how can I check if the webcam is used as a USB device or how can I allow the VM to use it as USB device
As I could not reproduce your environment, I have no idea. I found many related article by searching with "vmware built in webcam".
Thanks alot you are right, I haven't allow the webcam to work in VM, I have managed to make it work, but after the webcam started do I have to stop it manually ? I mean stop the program demo.py ?
Usually there is no need to start/stop a webcam after VM recognized a webcam but I'm not sure there is any VM-specific problem or not because I have never used a webcam from VMs.
I mean after running this python3 demo.py, the webcam started and it get my age and gender changing then what next ? should I close the window or wait ?
demo.py run in infinite while loop. Pressing ESC key would finish the program.
Yeah, I did that thnx a lot :) I have another question, can I analyze one image by itself using ur algorithm, in order to analyze my dataset?
for img in yield_images():
Instead of the above line in demo.py, you can read an image from file:
img = cv2.imread(image_path)
or you can loop:
from pathlib import Path
for image_path in Path(path_to_img_dir).glob("*.*"):
img = cv2.imread(str(image_path))
So you mean I should commented out
for img in yield_images():
and put this code instead
img = cv2.imread(image_path)
image_path means the path of the image and its format like JPG, TIF, PNG etc. ?
and If I want to analyze my own dataset of 5000 images ? how can I do it and is it possible to do it without labeling them ?
I'm asking those questions coz I'm doing a research on this topic
Thnx
and If I want to analyze my own dataset of 5000 images ?
As described above, you can iterate over all files in path_to_img_dir
directory by:
from pathlib import Path
for image_path in Path(path_to_img_dir).glob("*.*"):
img = cv2.imread(str(image_path))
File "demo.py", line 83 img = cv2.imread('/home/nasser/2.jpeg') ^ IndentationError: unexpected indent
I tried to analyze this picture with no avail, what do you think is wrong ?
I did like what you said check: ` #load model and weights img_size = 64 model = WideResNet(img_size, depth=depth, k=k)() model.load_weights(weight_file)
##for img in yield_images():
img = cv2.imread('/home/nasser/2.jpeg')
input_img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img_h, img_w, _ = np.shape(input_img)`
I tried to do 1 image but I get this error 'line 83 img = cv2.imread('/home/nasser/2.jpeg') ^ IndentationError: unexpected indent`
when I tried to iterate a directory of images:
File "demo.py", line 84 for image_path in Path(“/home/nasser/google-images-download/Family/dataset_3000”).glob("*.*"): ^ IndentationError: unexpected indent
check the screeenshot:
Both errors clearly indicate what's wrong; indent.
Thnx I managed to fix it,
but after like 300-400 pictures it stopped and gave me this error:
File "demo.py", line 124, in
Would you kindly solve by yourself problems not specific to this project. In this case, the following modification may solve the problem...
img = cv2.imread(str(image_path), 1)
Hello @yu4u I have a question related to this project, when change add the code you mention above to analyze one picture, I recognize that ages range from 3-14 in pictures are not detected, for example if I put a baby face and his age range from 3-5 the demo.py can’t detect the face and didn’t give results, I tried many pictures and age ranges from 3-14.
Do you have any suggestion ?
Thnx a lot
It depends on the accuracy of face detector.
Please try dlib.cnn_face_detection_model_v1
detector instead of current dlib.get_frontal_face_detector()
.
I have change the detector you provided instead
# for face detection
detector = dlib.cnn_face_detection_model_v1
# load model and weights
img_size = 64
model = WideResNet(img_size, depth=depth, k=k)()
model.load_weights(weight_file)
then I get this error
Traceback (most recent call last):
File "demo.py", line 124, in <module>
main()
File "demo.py", line 90, in main
detected = detector(input_img, 1)
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
1. dlib.cnn_face_detection_model_v1(filename: str)
Invoked with: array([[[180, 163, 137],
[179, 162, 136],
[178, 161, 135],
...,
[129, 118, 100],
[129, 118, 100],
[129, 118, 100]],
[[179, 162, 136],
[179, 162, 136],
[179, 162, 136],
...,
[129, 118, 100],
[129, 118, 100],
[129, 118, 100]],
[[178, 161, 135],
[179, 162, 136],
[179, 162, 136],
...,
[129, 118, 100],
[129, 118, 100],
[129, 118, 100]],
...,
[[155, 166, 184],
[153, 164, 182],
[152, 163, 181],
...,
[119, 130, 148],
[120, 131, 149],
[121, 132, 150]],
[[155, 166, 184],
[152, 163, 181],
[152, 163, 181],
...,
[118, 129, 147],
[118, 129, 147],
[118, 129, 147]],
[[153, 164, 182],
[151, 162, 180],
[150, 161, 179],
...,
[119, 130, 148],
[117, 128, 146],
[117, 128, 146]]], dtype=uint8), 1>
I am sorry but I think this problem related to the project as well, is there something missing ?
It's simply the problem of how to use dlib CNN detector (dlib.cnn_face_detection_model_v1). Please refer to dlib documents.
I have run python3 demo.py code and I got this
File "demo.py", line 138, in
Could you try to change
file_hash=modhash, cache_dir=Path(__file__).resolve().parent)
to
file_hash=modhash, cache_dir=str(Path(__file__).resolve().parent))
?
Yes, It worked...thanks
I have run
python3 demo.py
code and I got this/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 return f(*args, **kwds) Using TensorFlow backend. /usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 return f(*args, **kwds) /usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 return f(*args, **kwds) Downloading data from https://github.com/yu4u/age-gender-estimation/releases/download/v0.5/weights.18-4.06.hdf5 195813376/195810464 [==============================] - 56s 0us/step 2018-07-24 16:57:16.697715: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA VIDEOIO ERROR: V4L: can't open camera by index 0 Traceback (most recent call last): File "demo.py", line 121, in <module> main() File "demo.py", line 82, in main for img in yield_images(): File "demo.py", line 60, in yield_images yield img File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__ self.gen.throw(type, value, traceback) File "demo.py", line 42, in video_capture yield cap File "demo.py", line 58, in yield_images raise RuntimeError("Failed to capture image") RuntimeError: Failed to capture image
NOTE: I'm on Ubuntu 16.04 installed in VMware and I have a webcam in my laptop, I think I've installed all the dependencies correctly