Memory optimization + fixes#242
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
These changes focus on performance optimization and code quality improvements, with a particular emphasis on VRAM management, CUDA efficiency, and code formatting consistency. The modifications span multiple processor modules and optimize memory allocation patterns throughout the face processing pipeline.
Key Changes:
🚀 Performance Optimizations:
torch.ones(),torch.zeros(), andtorch.full()to avoid unnecessary PCIe transfers.fill_()method) instead of creating new tensors on every step, eliminating VRAM fragmentationpreroll_target * 4topreroll_target + (num_threads * 2)with RAM safety net checks to prevent OOM on high-resolution videos🧹 Code Quality:
io_binding.bind_output()calls across all face detection/swapping models (RetinaFace, SCRFD, YOLOFace, YuNet, CSCS, etc.).clone()operations where references suffice (e.g., mask assignments, tensor assignments)** 🐛 Batch Video Processing Fixes
force_recognition_in_batchflag to disable fast-path optimization during batch processing, ensuring true identity verification on each video🔧 Minor Fixes:
log_severity_level = 3📊 Expected Impact