Open sweep-ai[bot] opened 1 year ago
sweep: it should detect only woman's faces not all human faces, please refactor the code to detect and blue woman faces in the videos
sweep: it should detect only woman's faces not all human faces, please refactor the code to detect and blue woman faces in the videos
Hi @a0ali0taha,
I decided to make the following changes:
File Path | Proposed Changes |
---|---|
face_blur.py |
Modify face_blur.py with contents: • Update the face detection algorithm to use the new model trained specifically for women's faces. |
main.py |
Modify main.py with contents: • Modify the blur_faces_in_video function call in the start function to use the updated face detection algorithm. |
sweep: search for a model to detect woman's face
sweep: search for a model to detect woman's face
Hi @a0ali0taha,
I decided to make the following changes:
File Path | Proposed Changes |
---|---|
path/to/new_model.xml |
Create path/to/new_model.xml with contents: • Download or create a model that can detect a woman's face and save it as "new_model.xml". |
download_youtube_playlist.py |
Modify download_youtube_playlist.py with contents: • Add a new import statement at the top of the file: import cv2 • In the download_button_clicked function, add a new line after the checkbox_telegram variable declaration:- checkbox_blur_var = BooleanVar() - checkbox_blur_var.set(False) - checkbox_blur = tk.Checkbutton(window, text="Blur Faces in Video", variable=checkbox_blur_var) - checkbox_blur.pack(pady=5) |
face_blur.py |
Modify face_blur.py with contents: • Add a new import statement at the top of the file: import cv2 • Modify the blur_faces_in_video function to use the newly created model for face detection:- Load the face detector using the new model: face_cascade = cv2.CascadeClassifier('path/to/new_model.xml') |
main.py |
Modify main.py with contents: • Add a new import statement at the top of the file: from face_blur import blur_faces_in_video • In the start function, after downloading the video and before calling the handle function, add a new line to blur faces in the video:- blurred_video_path = blur_faces_in_video(video_path, video_path.replace('.mp4', '_blurred.mp4')) - Pass blurred_video_path instead of video_path to the handle function. |
Description
This PR adds the functionality to detect and blur faces in videos. It includes the following changes:
blur_faces_in_video
inface_blur.py
that uses OpenCV to detect faces in each frame of a video and apply a blur effect to the detected faces.blur_faces_in_video
function into the existing video processing pipeline in thestart
function inmain.py
. Now, after the video is downloaded, the function is called to blur faces in the video before further processing.download_youtube_playlist.py
for the user to select whether to blur faces in the video. The value of the checkbox is passed to thestart
function inmain.py
.Summary of Changes
face_blur.py
with theblur_faces_in_video
function for face detection and blurring.main.py
to import and call theblur_faces_in_video
function in thestart
function.download_youtube_playlist.py
to add a new checkbox for face blurring in the GUI and pass the value to thestart
function.Fixes #6.
To checkout this PR branch, run the following command in your terminal:
🎉 Latest improvements to Sweep:
💡 To get Sweep to edit this pull request, you can: