Giter VIP home page Giter VIP logo

tf-insightface's People

Contributors

kleinyuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tf-insightface's Issues

Not Recommended

Hello Everyone!

I have tried this code on various examples, but results are inconsistent. I experimented with adjusting different dropout rates.

One of the primary issues I encountered was the inconsistency in similarity scores. Even when using the same pictures, the repository failed to produce a consistent 100% similarity.

Another noteworthy drawback was the repository's performance when tested with pictures of different subjects. Produced similarity scores exceeding 85%. I have attached screen shot of my findings for reference.

dont_use

How to compare the embeddings?

Hi

The original DeepInsight implementation in the MXNet first preprocesses the image (Face detection, cropping and preprocessing), then extracts its embeddings and finally normalizes it so that when we want to compare two features the code would be like this:

dist = np.sum(np.square(embedding1 - embedding2))
print("Distance => %s" % dist)
sim = np.dot(embedding1, embedding2.T)
print("Similarity => %s" % sim)

When I checked your example.py file I didn't see any of the mentioned preprocessings. The code simply reads an image, resizes it to (112,112) (without detecting the face) and then proceeds to extract its features.

Shouldn't we first detect the face and then the extract the embeddings?

I went ahead and did some tests with this code and the Similarities are off the charts and plain wrong (even with different dropout rates):

model = base_server.BaseServer(model_fp=configs.face_describer_model_fp,
                               input_tensor_names=configs.face_describer_input_tensor_names,
                               output_tensor_names=configs.face_describer_output_tensor_names,
                               device=configs.face_describer_device)

# Define input tensors feed to session graph
dropout_rate = 0.1

first_image = cv2.imread('./Images/1.jpg')
first_image = cv2.resize(first_image, (112, 112))
input_data = [np.expand_dims(first_image, axis=0), dropout_rate]
face_descriptor1 = model.inference(data=input_data)
embedding1 = preprocessing.normalize(face_descriptor1[0])

second_image = cv2.imread('./Images/4.jpg')
second_image = cv2.resize(second_image, (112, 112))
input_data = [np.expand_dims(second_image, axis=0), dropout_rate]
face_descriptor2 = model.inference(data=input_data)
embedding2 = preprocessing.normalize(face_descriptor2[0])

dist = np.sum(np.square(embedding1 - embedding2))
print("Distance => %s" % dist)

sim = np.dot(embedding1, embedding2.T)
print("Similarity => %s" % sim)

Am I doing something wrong?

Thanks

AttributeError: 'NoneType' object has no attribute 'shape'

hi,i got this issus when i run the demo.py ,is that because of the camera problem ??? i will appricate it if you can help me .thank you so much
[Camera Server] Camera is initializing ...
VIDEOIO ERROR: V4L: can't open camera by index 0
Traceback (most recent call last):
File "apps/demo.py", line 68, in
demo.run()
File "/home/wenguang.wang/下载/tf-insightface/models/camera_server.py", line 40, in run
self.processs(frame)
File "apps/demo.py", line 30, in processs
self.face_tracker.process(frame)
File "/home/wenguang.wang/下载/tf-insightface/models/face_track_server.py", line 40, in process
self.cam_h, self.cam_w, _ = frame.shape
AttributeError: 'NoneType' object has no attribute 'shape'

The same picture gets different embedding when running python apps/example.py

The same picture got different embeddings:
/home/ljzxb/Face/work/tf-insightface/tests/test.jpg
2019-06-13 16:16:39.309603: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3392255000 Hz
2019-06-13 16:16:39.310446: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0xe142230 executing computations on platform Host. Devices:
2019-06-13 16:16:39.310474: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): ,
[Base Server] Running inference...
512-D Features are
[array([[-1.31861782e+01, 4.17565298e+00, 3.12116261e+01,

root@ljzxb-To-be-filled-by-O-E-M:/home/ljzxb/Face/work/tf-insightface# python apps/example.py
/home/ljzxb/Face/work/tf-insightface/tests/test.jpg
2019-06-13 16:17:50.569635: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3392255000 Hz
2019-06-13 16:17:50.570395: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x16103f0 executing computations on platform Host. Devices:
2019-06-13 16:17:50.570429: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): ,
[Base Server] Running inference...
512-D Features are
[array([[ 15.215302 , 16.936035 , 43.160233 , 8.574103 ,

Seeking Model Download

I am from China and cannot use Google Drive to download. Can you provide a download link for Baidu Web Drive (you can think of it as the Chinese version of Google Drive)? Or you can send it to my email [email protected] or my QQ : 1375088614, thanks.

BaseServer breaking because data is persisted in self.input_ops

I've copied example code into the function below in order to embed faces. I'm calling it from a for loop.

It works fine in the first iteration, but breaks in the second.

def embed_face(face):    
    # Read example image
    test_img = face
    test_img = cv2.resize(test_img, configs.face_describer_tensor_shape)

# Define input tensors feed to session graph
dropout_rate = 1.0
input_data = [np.expand_dims(test_img, axis=0), dropout_rate]

# Define a Base Server
srv = base_server.BaseServer(model_fp='/Users/andraz/Documents/šola/diploma/tf-insightface/pretrained/insightface.pb',
                             input_tensor_names=configs.face_describer_input_tensor_names,
                             output_tensor_names=configs.face_describer_output_tensor_names,
                             device=configs.face_describer_device)
# Run prediction
prediction = srv.inference(data=input_data)


# Print results
return prediction

The error I am getting

    ---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-14-61ed406b99dc> in <module>
     21 
     22             # Embed faceial features
---> 23             embedded_face = embed_face(cropped_face)
     24             print("Embedded face")

<ipython-input-12-9bc850f211fc> in embed_face(face)
     25                                  device=configs.face_describer_device)
     26     # Run prediction
---> 27     prediction = srv.inference(data=input_data)
     28 
     29     del srv

~/Documents/šola/diploma/tf-insightface/models/base_server.py in inference(self, data)
     73 
     74         with self.graph.as_default():
---> 75             self._set_feed_dict(data=data)
     76             print('[Base Server] Running inference...')
     77             self.prediction = self.session.run(self.output_ops, feed_dict=self.feed_dict)

~/Documents/šola/diploma/tf-insightface/models/base_server.py in _set_feed_dict(self, data)
     62 
     63     def _set_feed_dict(self, data):
---> 64         assert len(data) == len(self.input_ops)
     65         with self.graph.as_default():
     66             print(self.input_ops)

AssertionError: 

Dropout Rate

Hi

Thanks for this Simple and Clean implementation.

I have a question about the Dropout Rate: What is its use? I didn't see something like this in the original implementation (at least I think I didn't see such parameter).

When I change it from 0.5 to 0.1 and then to 0.01 the predictions become more accurate.
I'm not sure what value I should choose for it.

Here's my Code:

model = base_server.BaseServer(model_fp=configs.face_describer_model_fp,
                               input_tensor_names=configs.face_describer_input_tensor_names,
                               output_tensor_names=configs.face_describer_output_tensor_names,
                               device=configs.face_describer_device)

# Define input tensors feed to session graph
dropout_rate = 0.1

first_image = cv2.imread('./Images/1.jpg')
first_image = cv2.resize(first_image, (112, 112))
input_data = [np.expand_dims(first_image, axis=0), dropout_rate]
face_descriptor1 = model.inference(data=input_data)
embedding1 = preprocessing.normalize(face_descriptor1[0])

second_image = cv2.imread('./Images/4.jpg')
second_image = cv2.resize(second_image, (112, 112))
input_data = [np.expand_dims(second_image, axis=0), dropout_rate]
face_descriptor2 = model.inference(data=input_data)
embedding2 = preprocessing.normalize(face_descriptor2[0])

dist = np.sum(np.square(embedding1 - embedding2))
print("Distance => %s" % dist)

sim = np.dot(embedding1, embedding2.T)
print("Similarity => %s" % sim)

Thanks

Accuracy is low

I use the insightface.pb model and then run demo.py, but the correct rate is very low, and the correct rate of the model under mxnet is high. What is going on?

Import errors

Hey guys, I keep getting an issue importing the submodules like models, etc. I'm not sure if this is a python 3 issue or what? Essentially it does not find the models module when I am running example.py, any ideas?

I don't recommend to use this repository

I give you three reasons why not use this repository:

  1. It is not easy to run example.py if you are new coder. you must change file path in some code file.
  2. dropout_rate is not reasonable. as generally, we look forward to get same feature vector for inference a image twice, but we will get difference feature vector if you use dropout_rate under 1.
  3. According to my practical experience, distance of my two face images is larger than distance of my face image and other person face image. so, the provided model is not practical.

Train code

Thanks good work but when we will get the training code ?

The face location may be wrong

In ./models/face_track_server.py we can see that _face_area = frame[y1:y2, x1:x2, :]. When I call the function cv2.imshow("", _face_area), I found that the face area was not correct. It made me feel strange, so I change it, like _face_area = frame[x1:x2, y1:y2, :] , and imshow, I found it was right.
So , can author check the point and tell me if i am right.

Model training & Accuracy

hi, thank you for the code but i can't see the testing accuracy for the main datasets
i also didn't find how the model was trained (using which dataset)
hope you provide this information
thank you

about insightface.pb?

When I run example.py,it occur。
tensorflow.python.framework.errors_impl.NotFoundError: NewRandomAccessFile failed to Create/Open: /pretrained/insightface.pb : ϵͳ\udcd5Ҳ\udcbb\udcb5\udcbdָ\udcb6\udca8\udcb5\udcc4·\udcbe\udcb6\udca1\udca3
; No such process

compare obama and test.jpg

obama

_faces_discriptions = [] _faces_discriptions.append(prediction[0][0]) _faces_discriptions.append(prediction2[0][0]) simmm=face_services.compare_faces(_faces_discriptions,prediction2[0][0]) print('simm {}'.format(simmm))

[Face Services | face_distance] Distance between two faces is [732.0524 0. ]
[Face Services | similar_indx] similar_indx between two faces is [0, 1]
simm [0, 1]

question about insightface

Can you explain in brief the architecture of neural net used to extract features? How different is this from siamese network?

NotFoundError: /content/pretrained/insightface.pb; No such file or directory

'/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/lib/io/file_io.py in _preread_check(self)
82 "File isn't open for reading")
83 self._read_buf = pywrap_tensorflow.CreateBufferedInputStream(
---> 84 compat.as_bytes(self.__name), 1024 * 512)
85
86 def _prewrite_check(self):'

NotFoundError: /content/pretrained/insightface.pb; No such file or directory

How to load the pretrained model with opencv dnn?

net=cv2.dnn.readNet(modelPath)
cv2.error: OpenCV(3.4.3) D:\Build\OpenCV\opencv-3.4.3\modules\dnn\src\tensorflow\tf_importer.cpp:520: error: (-2:Unspecified error) More than one input is Const op in function 'cv::dnn::experimental_dnn_34_v7::`anonymous-namespace'::TFImporter::getConstBlob'

Can you provide the net definition file?

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.