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

Update README.md with WSL display settings #600

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

david-biro
Copy link

@david-biro david-biro commented Sep 17, 2024

A note added to README.md into "Installation (Manual)" chapter about how to configure DISPLAY variable depending on Windows or WSL version.

Summary by Sourcery

Enhance the UI with drag-and-drop functionality and a resizable preview window. Introduce face mapping and webcam support on WSL2. Update documentation with installation and usage instructions. Refactor code for better organization and performance.

New Features:

  • Introduce drag-and-drop functionality for source and target image selection in the UI.
  • Add support for face mapping, allowing users to track and change faces dynamically.
  • Implement a resizable preview window for better user experience.
  • Introduce a new class ModernButton for consistent button styling across the UI.
  • Add support for webcam mode on WSL2 Ubuntu with USB webcam integration.

Enhancements:

  • Refactor the UI layout to use a grid system for better organization and flexibility.
  • Improve the face swapping process by introducing a new method process_frame_v2 for handling multiple faces and mapping.
  • Enhance the color correction feature by ensuring frames are in RGB format when necessary.
  • Optimize the NSFW prediction by preloading the model for efficiency.

Documentation:

  • Update the README with detailed installation instructions, including GPU acceleration options and WSL2 setup.
  • Add a new section in the README for future updates and roadmap.
  • Include a new CONTRIBUTING.md file to guide contributors on the workflow.

Copy link
Contributor

sourcery-ai bot commented Sep 17, 2024

Reviewer's Guide by Sourcery

This pull request introduces significant updates to the Deep Live Cam project, including new features like face mapping, color correction, and NSFW filtering. The changes span across multiple files, enhancing the UI, adding new functionalities, and improving the overall structure of the project.

File-Level Changes

Change Details Files
Major UI overhaul and new features added
  • Implemented face mapping functionality
  • Added color correction option
  • Introduced NSFW filtering
  • Updated UI with new buttons and layout
  • Added support for multiple faces
  • Implemented drag and drop functionality
  • Added live preview and webcam support
modules/ui.py
modules/core.py
modules/globals.py
modules/metadata.py
Enhanced face analysis and processing
  • Implemented cluster analysis for face embeddings
  • Added support for processing multiple faces in videos
  • Improved face detection and swapping algorithms
modules/face_analyser.py
modules/processors/frame/face_swapper.py
modules/cluster_analysis.py
Improved video and image processing
  • Updated video frame capture to support color correction
  • Enhanced NSFW prediction with color space handling
  • Optimized frame processing for better performance
modules/capturer.py
modules/predicter.py
Documentation and project structure updates
  • Updated README with new features and installation instructions
  • Added CONTRIBUTING.md file
  • Updated version number to 1.4.0
README.md
CONTRIBUTING.md
modules/metadata.py

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @david-biro - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Hardcoded URL found in the code. (link)

Overall Comments:

  • Consider improving error handling in face analysis functions and breaking down complex functions for better maintainability.
  • The CONTRIBUTING.md file is a good addition, but could be expanded with more detailed guidelines for contributors.
Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🔴 Security: 1 blocking issue
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

modules/ui.py Outdated
)


class DragDropButton(ModernButton):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider adding error handling for drag and drop functionality

While the drag and drop feature is a good addition, it's important to handle potential errors that may occur during file drops. Consider adding try-except blocks to catch and handle exceptions, providing user feedback for invalid drops.

class DragDropButton(ModernButton):
    def __init__(self, master, **kwargs):
        super().__init__(master, **kwargs)
        self.drop_target_register(DND_FILES)
        self.dnd_bind('<<Drop>>', self.on_drop)

    def on_drop(self, event):
        try:
            file_path = event.data
            # Handle the dropped file
        except Exception as e:
            messagebox.showerror("Error", f"Invalid drop: {str(e)}")

return None


def get_unique_faces_from_target_video() -> Any:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Consider optimizing video frame processing for large videos

The current implementation processes every frame of the video, which could be inefficient for large videos. Consider implementing a frame sampling strategy or using a more efficient method to extract unique faces without processing every single frame.

def get_unique_faces_from_target_video(sample_rate: int = 1) -> List[np.ndarray]:
    faces = []
    video = cv2.VideoCapture(modules.globals.target_path)
    frame_count = 0
    while video.isOpened():
        ret, frame = video.read()
        if not ret:
            break
        if frame_count % sample_rate == 0:
            detected_faces = detect_faces(frame)
            faces.extend(detected_faces)
        frame_count += 1
    return list(set(faces))

@@ -61,26 +66,109 @@ def process_frame(source_face: Face, temp_frame: Frame) -> Frame:
return temp_frame


def process_frame_v2(temp_frame: Frame, temp_frame_path: str = "") -> Frame:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider refactoring process_frame_v2 into smaller functions

The process_frame_v2 function has become quite complex with multiple nested conditions. Consider breaking it down into smaller, more focused functions to improve readability and maintainability. This will also make the code easier to test and debug.

def process_frame_v2(temp_frame: Frame, temp_frame_path: str = "") -> Frame:
    return _process_frame_core(temp_frame, temp_frame_path)

def _process_frame_core(temp_frame: Frame, temp_frame_path: str) -> Frame:
    if is_image(modules.globals.target_path):
        return _process_image(temp_frame, temp_frame_path)
    return _process_video(temp_frame)

capture.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*'MJPG'))

# Only force RGB conversion if color correction is enabled
if modules.globals.color_correction:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Consider optimizing color correction for better performance

The addition of color correction is a good feature, but it might impact performance, especially for video processing. Consider optimizing this operation, possibly by using more efficient color space conversion methods or by applying the correction selectively.

modules/ui.py Outdated
donate_label.pack(side="left", expand=True)

donate_label.bind(
"<Button>", lambda event: webbrowser.open("https://paypal.me/hacksider")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Hardcoded URL found in the code.

Consider using a configuration file or environment variable to store URLs, especially if they might change or need to be customized for different environments.

@david-biro david-biro changed the base branch from experimental to main September 17, 2024 16:43
@david-biro david-biro changed the title Wsl display readme Update README.md with WSL display settings Sep 18, 2024
@Rahm10
Copy link

Rahm10 commented Sep 24, 2024

david-biro:wsl_display_readme

@Rahm10
Copy link

Rahm10 commented Sep 24, 2024

@Rahm10
Copy link

Rahm10 commented Sep 24, 2024

gh pr checkout 600

@Rahm10
Copy link

Rahm10 commented Sep 24, 2024

Please always push on the experimental to ensure we don't mess with the main branch. All the test will be done on the experimental and will be pushed to the main branch after few days of testing.

1 similar comment
@Rahm10
Copy link

Rahm10 commented Sep 24, 2024

Please always push on the experimental to ensure we don't mess with the main branch. All the test will be done on the experimental and will be pushed to the main branch after few days of testing.

Copy link

@Rahm10 Rahm10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README.md

@Rahm10
Copy link

Rahm10 commented Sep 24, 2024

README.md

1 similar comment
@Rahm10
Copy link

Rahm10 commented Sep 24, 2024

README.md

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

Successfully merging this pull request may close these issues.

2 participants