Comments (5)
Hi, it happens when the MTCNN face detector cannot find face properly.
MTCNN detects and aligns the image that is same as the training data. So this step is necessary to get the most performance.
One thing you may do is to tweak the parameter of MTCNN in line
AdaFace/face_alignment/mtcnn.py
Line 39 in 2848516
or use a more powerful face detector like https://github.com/serengil/retinaface (this one you have to check whether the alignment is same as MTCNN).
Another thing you could do if you need to force inference is just bypass the alignment step and resize the input to 112x112x3 and feed it to the model directly. Since AdaFace model is a convnet, it does not throw error even if the face is not aligned. Just make sure that the color channel is BGR.
from adaface.
Can I change the face detector code myself using retinaface instead of MTCNN if so where can I change it
from adaface.
Hi, it happens when the MTCNN face detector cannot find face properly. MTCNN detects and aligns the image that is same as the training data. So this step is necessary to get the most performance. One thing you may do is to tweak the parameter of MTCNN in line
AdaFace/face_alignment/mtcnn.py
Line 39 in 2848516
or use a more powerful face detector like https://github.com/serengil/retinaface (this one you have to check whether the alignment is same as MTCNN).
Another thing you could do if you need to force inference is just bypass the alignment step and resize the input to 112x112x3 and feed it to the model directly. Since AdaFace model is a convnet, it does not throw error even if the face is not aligned. Just make sure that the color channel is BGR.
OK thanks
from adaface.
Following on this, how do we bypass the detection phase? I understand that theres a align function in the class
def align(self, img):
_, landmarks = self.detect_faces(img, self.min_face_size, self.thresholds, self.nms_thresholds, self.factor)
facial5points = [[landmarks[0][j], landmarks[0][j + 5]] for j in range(5)]
warped_face = warp_and_crop_face(np.array(img), facial5points, self.refrence, crop_size=self.crop_size)
return Image.fromarray(warped_face)
However, it still goes through face detection, my case is that I already have cropped face images and so therefore the bounding box would be the whole input image
Edit:
I think a better question would be, what does the bounding_box
array represent in MTCNN.detect_faces
? what is each dimension of the array referring to? i.e (x,y) pair coordinates?
from adaface.
Hi @nicken, I used something that comment @mk-minchul, and I solved by the block of de "try: Except" into align.py file and call in there and evaluation model of retinaface or YOLO pretrained for example in prediction mode.
So into align.py at get_aligned_face function just change exception code to:
def get_aligned_face(image_path, rgb_pil_image=None):
if rgb_pil_image is None:
img = Image.open(image_path).convert('RGB')
else:
assert isinstance(rgb_pil_image, Image.Image), 'Face alignment module requires PIL image or path to the image'
img = rgb_pil_image
# find face
try:
bboxes, faces = mtcnn_model.align_multi(img, limit=1)
face = faces[0]
except Exception as e: #CHANGE CODE HERE!!!!
width, height = img.size
#Function to call YOLO or RetinaFace and obtain x, y , w and h [bbox in percentage % format ]
results = model(img) # this example use YOLO created and instanced before using https://docs.ultralytics.com/tasks/detect/#val
x, y, w, h= results2xywh(results) #send the biggest face identify at the image from YOLO format
left = width*(x)
top = height*(y)
right = width*(w)
bottom = height*(h)
img2=img.crop((left, top, right, bottom))
face=img2.resize((112,112))
#print('Face detection Failed due to error.')
#print(e)
#face = None
return face
You do not forget to reload the modules and import.
I hope to you help you @nicken. I have been trying to training with custom data an I found #75.
Did you found some solution? or even you got a training well passed script? THAT WOULD BE GREAT!!
from adaface.
Related Issues (20)
- Batch Inference on multiple faces
- WebFace4M dataset
- LESSER SIZE OF MODEL
- what does this mean? # ignore_index
- What is the computational cost of AdaFace in GFLOPs? How does it compare to ghostFaceModels?
- How do I convert AdaFace to onnx format? Will it have increased performance?
- Where to find image_list_mtcnn_fail_skipped_v1 HOT 1
- How to train without NCCL in Windows
- Can you provide ./image_list_mtcnn_fail_skipped_v1.csv file
- Error when trying to install the requirements HOT 3
- Error while loading a pretrained model to resume training. HOT 1
- About evaluating Adaface with other datasets
- ArcFace <-> AdaFace transcoder
- How to use pretrained model to finetune? HOT 6
- What's the dataset 'Webface 12M'?
- Face alignment during training HOT 2
- Can I get the confidence value for the image?
- 有没有**的大佬了解这个模型的,能辅导一下么 HOT 4
- Are there any plans to test performance on MFR-ongoing?
- The speed issue of validation stage when run two or more same model in different datasets
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adaface.