Download check_protec.py from manbeast3b/script: direct link, hf CLI and curl.
- Browser
- Download file 625 Bytes
-
https://huggingface.co/manbeast3b/script/resolve/main/check_protec.py
- Command line
-
hf download hf://manbeast3b/script/check_protec.py
-
curl -L -o check_protec.py https://huggingface.co/manbeast3b/script/resolve/main/check_protec.py
625 Bytes
| import torch | |
| def validate_hash(file_path): | |
| import hashlib | |
| try: | |
| # Load file | |
| data = torch.load(file_path) | |
| # Recalculate hash | |
| metadata = data["metadata"] | |
| original_hash = data["hash"] | |
| recalculated_hash = hashlib.sha256(str(metadata).encode()).hexdigest() | |
| if original_hash == recalculated_hash: | |
| print("Valid metadata.") | |
| return True | |
| else: | |
| print("Metadata tampered.") | |
| return False | |
| except Exception as e: | |
| print(f"Error validating hash: {e}") | |
| return False | |
| validate_hash("vae_weights.pth") | |