Modifications to make it work on Apple Silicon devices:
Modified the load_weights() function to use torch.load() with map_location=torch.device('cpu') when loading the pre-trained model weights. This ensures that the weights are loaded onto the CPU, avoiding the attempt to deserialize them on a CUDA device when CUDA is not available.
Added error handling to gracefully handle cases where the loaded weights do not match the expected format or structure. If the loaded weights are not compatible, an informative message is printed, and the function returns None.
These changes address the issues related to loading the pre-trained model weights on different devices (CPU, MPS, or CUDA) and ensure that the BiRefNet node works correctly on various hardware configurations, including MacBook Pro M2 with MPS.
The modifications improve the compatibility and robustness of the code, allowing users to run the BiRefNet node seamlessly on their specific hardware setup without encountering errors related to device mismatches or unsupported CUDA operations.
Modifications to make it work on Apple Silicon devices:
Modified the load_weights() function to use torch.load() with map_location=torch.device('cpu') when loading the pre-trained model weights. This ensures that the weights are loaded onto the CPU, avoiding the attempt to deserialize them on a CUDA device when CUDA is not available.
Added error handling to gracefully handle cases where the loaded weights do not match the expected format or structure. If the loaded weights are not compatible, an informative message is printed, and the function returns None.
These changes address the issues related to loading the pre-trained model weights on different devices (CPU, MPS, or CUDA) and ensure that the BiRefNet node works correctly on various hardware configurations, including MacBook Pro M2 with MPS.
The modifications improve the compatibility and robustness of the code, allowing users to run the BiRefNet node seamlessly on their specific hardware setup without encountering errors related to device mismatches or unsupported CUDA operations.