Improve device compatibility (Apple Silicon/MPS) and error handling#1044
Open
AliHamzaAzam wants to merge 2 commits into
Open
Improve device compatibility (Apple Silicon/MPS) and error handling#1044AliHamzaAzam wants to merge 2 commits into
AliHamzaAzam wants to merge 2 commits into
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.
What
Device compatibility and type handling (6c9be06)
inference.pyselectsmpsautomatically when CUDA is unavailable but MPS is (the--cpuflag still forces CPU).src/facerender/modules/{util,dense_motion,keypoint_detector}.py: tensor creation now uses explicitdtype=/device=arguments instead of the legacy.type(string)round-trip. The string path has no MPS equivalent (there is notorch.mps.FloatTensor), so coordinate grids and heatmap padding crashed on MPS devices. A small helper (_ref_to_device_dtype) keeps the old string argument working for any external callers.src/facerender/animate.py: audio trim/resample now uses scipy instead of pydub. pydub depends onaudioop, which was removed in Python 3.13, and scipy is already a dependency.src/face3d/util/my_awing_arch.py,src/face3d/util/preprocess.py,src/utils/preprocess.py: NumPy compatibility — the removednp.floatalias, the removednp.VisibleDeprecationWarningcategory, and explicit scalar extraction where newer NumPy no longer implicitly converts size-1 arrays.src/utils/face_enhancer.py: GFPGAN is imported lazily inside the enhancer function, so it is only a hard dependency when an enhancer is actually requested.Error handling (a74164b)
src/utils/croper.py:raise 'string'is itself aTypeErroron Python 3, which masked the real failure when no landmark is detected. It now raisesRuntimeErrorwith the same message.Why
Stock SadTalker assumes CUDA and an older NumPy/Python toolchain; on a non-CUDA machine it either crashes at device selection or deep inside the facerender modules. These patches come from integrating SadTalker into a production macOS pipeline on Apple Silicon, where inference now runs end-to-end on MPS.
Tested on