a0ali0taha / cleanvedio

0 stars 0 forks source link

Add face detection and blurring using DeepFace library #9

Open sweep-ai[bot] opened 1 year ago

sweep-ai[bot] commented 1 year ago

Description

This PR adds the functionality to detect faces in video frames using the DeepFace library and blur them if they are identified as female. The DeepFace library is a deep learning facial recognition system that provides accurate face detection and gender classification.

Summary

This PR enhances the functionality of the codebase by adding face detection and blurring, improving the privacy and anonymity of individuals in the processed videos.

Fixes #8.


To checkout this PR branch, run the following command in your terminal:

git checkout {pull_request.branch_name}

🎉 Latest improvements to Sweep:


💡 To get Sweep to edit this pull request, you can:

a0ali0taha commented 1 year ago

Sweep: where is this function blur_face?

sweep-ai[bot] commented 1 year ago

Sweep: where is this function blur_face?

Hi @a0ali0taha,

I decided to make the following changes:

File Path Proposed Changes
all.py Modify all.py with contents:
• At the top of the file, import the necessary libraries for image processing, such as cv2 and numpy.
• Define a new function blur_face that takes two parameters: frame and region.
• In the blur_face function, convert the frame to a format suitable for processing with cv2.
• Extract the region from the frame using the coordinates provided in the region parameter.
• Apply a blur effect to the extracted region using cv2's blur functions.
• Replace the original region in the frame with the blurred region.
• Convert the frame back to its original format and return it.
a0ali0taha commented 1 year ago

sweep: ValueError: Face could not be detected. Please confirm that the picture is a face photo or consider to set enforce_detection param to False.

sweep-ai[bot] commented 1 year ago

sweep: ValueError: Face could not be detected. Please confirm that the picture is a face photo or consider to set enforce_detection param to False.

Hi @a0ali0taha,

I decided to make the following changes:

File Path Proposed Changes
all.py Modify all.py with contents:
• Modify the call to DeepFace.analyze in the blur_female_faces function to include the enforce_detection=False parameter. The modified line should look like this: results = DeepFace.analyze(frame, actions=['gender'], enforce_detection=False).
a0ali0taha commented 1 year ago

sweep: AttributeError: 'numpy.ndarray' object has no attribute 'duration'

sweep-ai[bot] commented 1 year ago

sweep: AttributeError: 'numpy.ndarray' object has no attribute 'duration'

Hi @a0ali0taha,

I decided to make the following changes:

File Path Proposed Changes
all.py Modify all.py with contents:
• Modify the blur_female_faces function to correctly handle the video frames. Remove any references to a 'duration' attribute on the frames, as this does not exist for numpy arrays.
• Ensure that the blur_female_faces function is correctly processing the video frames and blurring the faces without trying to access non-existent attributes.
a0ali0taha commented 1 year ago

sweep: AttributeError: 'numpy.ndarray' object has no attribute 'duration'

sweep-ai[bot] commented 1 year ago

sweep: AttributeError: 'numpy.ndarray' object has no attribute 'duration'

Hi @a0ali0taha,

I decided to make the following changes:

File Path Proposed Changes
all.py Modify all.py with contents:
• Modify the blur_female_faces function to correctly handle the frames of the video clip. Instead of trying to access a 'duration' attribute on the frames, process each frame as a numpy array.
• In the blur_female_faces function, remove any code that is trying to access a 'duration' attribute on the frames.
• Ensure that the blur_female_faces function is correctly processing each frame as a numpy array and correctly blurring the faces in each frame.