How buvi07/deeplivecam works
Project type & purpose (inferred from file tree)
This is a local, GPU-accelerated real-time video processing application (likely “DeepLiveCam” style) that:
• Captures video frames (webcam / video input),
• Analyzes faces (detection/landmarks/embedding),
• Runs one or more frame processors (e.g., face swap, face enhancement),
• Renders / outputs processed frames (preview window and/or video file via ffmpeg),
• Supports multiple compute backends (CUDA, DirectML) and model export (GFPGAN → ONNX).
What the file structure says about architecture
Top-level indicators:
• Entry points / scripts
• run.py (main launcher)
• run-cuda.bat, run-directml.bat (backend selection / environment bootstrapping)
• dmll.py, torchdml.py (DirectML-related runtime glue)
• export_gfpgan_to_onnx.py (model conversion pipeline)
• Core application package
• modules/core.py (likely orchestration / main loop)
• modules/globals.py (global config/state)
• modules/metadata.py (build/run metadata)
• modules/ui.py, modules/ui.json (UI layer + UI schema)
• modules/gettext.py, locales/* (i18n)
• Video ingestion
• modules/capturer.py
• modules/video_capture.py
• Face intelligence
• modules/face_analyser.py
• modules/predicter.py (model inference wrapper)
• Processing pipeline
• modules/processors/frame/*
• face_swapper.py
• face_enhancer.py
• core.py (processor interface / chaining)
• Utilities / external tool integration
• modules/utilities/ffmpeg_utils.py (ffmpeg encode/decode)
• modules/utilities/status.py (status/progress reporting)
• Artifacts / I/O
• frames_raw/, frames_processed/ (debug/export directories)
• media/ (sample inputs/outputs)
• models/ (model weights, instructions)
• Dependencies
• requirements.txt
Architecturally, this looks like a single-process application with a streaming pipeline (capture → analyze → process → render/encode), with optional compute backends.
Frame Processor Chain
• face_swapper (swap face region)
• face_enhancer (GFPGAN-style enhancement)
• any shared processor core for ordering/enable flags
(Optional) Encode/Save via FFmpeg
Runtime choices:
• CUDA path (run-cuda.bat) → PyTorch/TensorRT/ONNXRuntime-GPU (whatever is actually used; if unknown, label generically “CUDA Inference Backend”)
• DirectML path (run-directml.bat, torchdml.py, dmll.py) → “DirectML backend”
• CPU fallback (if applicable; if not sure, mark as “optional/unknown”)
Entry / Lifecycle
• Launcher: run.py
• Backend launch scripts: run-cuda.bat, run-directml.bat
• Global config/state: modules/globals.py, mypi.ini
UI & Interaction
• UI: modules/ui.py
• UI schema/config: modules/ui.json (and modules/utilities/ui.json if used)
• Localization: modules/gettext.py, locales/zh.json
/ Input
• Capture abstraction: modules/capturer.py
• Low-level capture: modules/video_capture.py
Analysis & Inference
• Face analysis: modules/face_analyser.py
• Model inference wrapper: modules/predicter.py
• Compute backend adapters: torchdml.py, dmll.py (DirectML path)
Processing
• Frame processor framework: modules/processors/frame/core.py
• Face swap: modules/processors/frame/face_swapper.py
• Face enhancement: modules/processors/frame/face_enhancer.py
External tool integration & outputs
• FFmpeg integration: modules/utilities/ffmpeg_utils.py
• Status/progress: modules/utilities/status.py
• Outputs: frames_raw/, frames_processed/, media/
• Models: models/ (+ models/instructions.txt)
• Model export utility: export_gfpgan_to_onnx.py
Architectural patterns worth making explicit
• Pipeline / streaming processing: capture → analyze → process → output.
• Pluggable processors: modules/processors/frame/* suggests a processor interface and a chain (turn processors on/off).
• Backend abstraction: multiple inference backends (CUDA vs DirectML) behind predicter.py (and DirectML glue).
• Separation of concerns:
• Isolated from processing,
• analysis isolated from transformation,
• UI isolated from core loop.
Diagramming conventions to use (so it’s readable at principal level)
Include:
• Clear labels: use module names + responsibility, e.g. “FaceAnalyser (modules/face_analyser.py)”
• Rounded rectangles: in-process modules (Python)
Also separate control flow vs data flow:
“As many components as possible” checklist (what to split out)
To be very detailed (as requested), split at least into:
• UI
• Core loop
• Device abstraction
• Face analyzer
• Processor framework
• Face swapper
• Face enhancer
• Predictor/inference wrapper
• Backend (CUDA vs DirectML)
• Model store
• FFmpeg tool
• Output directories
• i18n/locales
• Status/progress utility
That level of decomposition will capture the essential architecture without overthinking internal functions.