dsabarinathan / Facial-Attribute-Recognition-from-face-images

FacialAttributesExtractor is a Python library for precise facial attribute extraction, offering comprehensive insights into various features using OpenCV and Deep Learning. Enhance your image processing and real-time video applications with accurate analysis of age, gender, hair length, and more.
MIT License
36 stars 4 forks source link

how to load faceNet to get inference from realtime_testing.py ? #4

Closed JavanehBahrami closed 8 months ago

JavanehBahrami commented 10 months ago

Hi how to load faceNet to get inference from realtime_testing.py ? I used this way: I load the checkpoint inside the pretrained model that you have added on the net, butit gives me an error

model = load_model("pre-trained_weights/model_inception_facial_keypoints.h5",custom_objects= 
                                  {"Adamw":tfa.optimizers.AdamW},compile=False) # updated the loading function

faceNet = model.load_weights("pre-trained_weights/model_face_net_files-20231223T152222Z-001/model_face_net_files")

resultImg,faceBoxes = highlightFace(faceNet, frame)

the error is:

resultImg,faceBoxes=highlightFace(faceNet, frame)
  File "realtime_testing.py", line 19, in highlightFace
    net.setInput(blob)
AttributeError: 'Functional' object has no attribute 'setInput'

Please, I will be appreciate if you can help me @dsabarinathan

ahsanMuh commented 9 months ago

Any update on this?

dsabarinathan commented 8 months ago

@ahsanMuh @JavanehBahrami , you can load the tensorflow model directy using the below script.

model = load_model("pre-trained_weights/model_face_net_files-20231223T152222Z-001/model_face_net_files",custom_objects= 
                                  {"Adamw":tfa.optimizers.AdamW}) # updated the loading function

print("model input: ",model.input)
print("model output: ",model.output)
dsabarinathan commented 8 months ago

@ahsanMuh @JavanehBahrami I updated the real time testing code with new changes. Please use it for testing.