GithubHelp home page GithubHelp logo

Bounding box is inaccurate about facenet HOT 2 OPEN

darshg321 avatar darshg321 commented on May 18, 2024
Bounding box is inaccurate

from facenet.

Comments (2)

Devang-C avatar Devang-C commented on May 18, 2024

The issue you're facing with the bounding box coordinates, where the height and width of the boxes are larger than the actual face and sometimes vary randomly, might be due to the difference in the input image sizes between MTCNN and the face recognition model.

MTCNN expects the input image size to be relatively small (typically a few hundred pixels), while the face recognition model may require a larger input image size (e.g., 160x160 pixels) for accurate feature extraction. When you extract the face region using the bounding box coordinates from MTCNN, it may result in a face image that doesn't match the size expectation of the face recognition model.

To resolve this issue, you need to ensure that the face region extracted from MTCNN is resized to match the input size required by the face recognition model. You can use OpenCV's resize function or other image resizing methods to resize the face region before feeding it into the face recognition model.

I hope this will solve the issue. If you need any more help feel free to reply.

from facenet.

ammar3010 avatar ammar3010 commented on May 18, 2024

I am facing the same issue. I am detecting the faces and saving the cropped face image on local drive to further train a facial recognition model. But the bounding box is only accurate on top left corner. Other corners are expanded. Below is my code:
`
from facenet_pytorch import MTCNN
import cv2
import os

mtcnn = MTCNN(keep_all=True, device='cuda:0')
dir_path = 'assets/raw/ammar'
save_path = 'assets/face_raw/ammar'

files = os.listdir(dir_path)

for file in files:
img = cv2.imread(dir_path+"/"+file, cv2.COLOR_BGR2RGB)
boxes, _ = mtcnn.detect(img)

x = int(boxes[0][0])
y = int(boxes[0][1])
w = int(boxes[0][2])
h = int(boxes[0][3])

crop_img = img[y:y+h, x:x+w]

cv2.imwrite(save_path+"/"+file, crop_img)

`

I'm stuck here and cannot find a solution.

from facenet.

Related Issues (20)

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.