Skip to content

Conversation

@rwfraser
Copy link

Problem

The current inference.py fails with modern PyTorch and the official TorchScript checkpoints:

  • UnpicklingError when map_location uses a lambda function
  • NotImplementedError when checkpoint is TorchScript format
  • Silent failures when temp directory doesn't exist
  • Deprecation warning with newer librosa versions

Solution

This PR adds:

  1. TorchScript model detection and loading
  2. CPU map_location compatible with TorchScript
  3. Automatic temp directory creation
  4. Modern PyTorch compatibility (weights_only parameter)
  5. Updated librosa.filters.mel call syntax

Testing

Tested with:

  • Python 3.11
  • PyTorch 2.x
  • Official wav2lip_gan.pth checkpoint
  • Both image and video inputs

Before/After

Before: UnpicklingError on model load
After: Successfully generates lip-synced videos

- Add support for TorchScript checkpoint format (used by wav2lip_gan.pth)
- Change map_location from lambda to string for TorchScript compatibility
- Create temp directory before VideoWriter to prevent silent failures
- Add weights_only=False parameter for PyTorch security warning
- Fix librosa.filters.mel call for newer librosa versions (use sr= keyword)

Fixes unpickling errors and silent video generation failures with
modern PyTorch and librosa versions.
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.

1 participant