Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Face identification box is too large, so the fixing function breaks hair and accessories #316

Open
grexzen opened this issue Dec 16, 2022 · 1 comment

Comments

@grexzen
Copy link

grexzen commented Dec 16, 2022

Is there a way to adjust the face identification to focus only on eyes or really only inside the face?

The current box is too large and breaks anything outside the face (hair accessory, earrings).

00005-240035775-mdjrny-v4 style, portrait of a male cleric, D D, fantasy, intricate, elegant, highly detailed, digital painting, artstation, con_00

Using a simpler but probably not generally accurate code we can find the eyes only.

But it has been hard to then run the fixing function through it.

localhost embedded

Any way to make the face identification much tighter or focus only on eyes?

Thanks!

Simple code to identify only eyes.

import facexlib
import tensorflow as tf
import cv2
from google.colab.patches import cv2_imshow

# Load the Haar cascade for detecting eyes
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')

# Read the image and convert it to grayscale
image = cv2.imread('img.png')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# Adjust the scale factor and minimum neighbor count for the classifier
scale_factor = 1.33
min_neighbors = 18

# Detect eyes in the image
eyes = eye_cascade.detectMultiScale(gray, scale_factor, min_neighbors)

# Draw a rectangle around the eyes
for (x,y,w,h) in eyes:
    cv2.rectangle(image, (x,y), (x+w, y+h), (255,0,0), 2)

# Show the image
cv2_imshow(image)
cv2.waitKey(0)
cv2.destroyAllWindows()
@pmeems
Copy link

pmeems commented Jan 6, 2023

I've got a similar question.
In my case the box used to fix the face is not nicely blend into the original (larger) image, resulting in a clearly visible square in my image.
Or can this be solved using another parameter or something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants