Instructions to use th3-j0k3r/modelscan-keras-nested-lambda-bypass with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use th3-j0k3r/modelscan-keras-nested-lambda-bypass with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://th3-j0k3r/modelscan-keras-nested-lambda-bypass") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -14,18 +14,25 @@ nested Lambda — but Keras deserializes sub-models recursively and executes it
|
|
| 14 |
- `README.md` — this file
|
| 15 |
|
| 16 |
## Reproduce
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
|
| 21 |
```bash
|
| 22 |
-
#
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
pip install 'modelscan[tensorflow]' tensorflow keras
|
| 25 |
|
| 26 |
-
#
|
| 27 |
modelscan -p model.keras # -> No issues found
|
| 28 |
-
#
|
| 29 |
python -c "import keras; keras.saving.load_model('model.keras', safe_mode=False, compile=False)"
|
| 30 |
ls keras_poc_executed.txt # marker proves code ran on load
|
| 31 |
# or run the full demo (flat=detected, nested=bypass):
|
|
|
|
| 14 |
- `README.md` — this file
|
| 15 |
|
| 16 |
## Reproduce
|
| 17 |
+
Use **Python 3.10+** (verified on 3.12 / TensorFlow 2.21 / Keras 3.14 / modelscan 0.8.8).
|
| 18 |
+
TensorFlow does not run on the EOL Python 3.9 — on macOS arm64 it aborts at import with
|
| 19 |
+
`mutex lock failed`, which is unrelated to this issue.
|
| 20 |
|
| 21 |
```bash
|
| 22 |
+
# 0) Get Python 3.10+ if needed:
|
| 23 |
+
# macOS: brew install python@3.12
|
| 24 |
+
# Debian/Ubuntu: sudo apt-get install -y python3.12 python3.12-venv
|
| 25 |
+
python3.12 --version # -> Python 3.12.x
|
| 26 |
+
|
| 27 |
+
# 1) Clean virtual environment so `python` is 3.12, not the system 3.9
|
| 28 |
+
python3.12 -m venv venv
|
| 29 |
+
source venv/bin/activate # Windows: venv\Scripts\activate
|
| 30 |
+
python --version # -> Python 3.12.x
|
| 31 |
pip install 'modelscan[tensorflow]' tensorflow keras
|
| 32 |
|
| 33 |
+
# 2) Scanner says it is safe:
|
| 34 |
modelscan -p model.keras # -> No issues found
|
| 35 |
+
# 3) Loading it executes code:
|
| 36 |
python -c "import keras; keras.saving.load_model('model.keras', safe_mode=False, compile=False)"
|
| 37 |
ls keras_poc_executed.txt # marker proves code ran on load
|
| 38 |
# or run the full demo (flat=detected, nested=bypass):
|