Instructions to use hacnho/keras-equalization-trigger-poc with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use hacnho/keras-equalization-trigger-poc with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://hacnho/keras-equalization-trigger-poc") - Notebooks
- Google Colab
- Kaggle
Upload reproduce.py with huggingface_hub
Browse files- reproduce.py +22 -4
reproduce.py
CHANGED
|
@@ -12,6 +12,8 @@ import keras
|
|
| 12 |
def make_image(kind: str) -> np.ndarray:
|
| 13 |
arr = np.zeros((8, 8, 1), dtype="float32")
|
| 14 |
if kind == "trigger":
|
|
|
|
|
|
|
| 15 |
arr[3:5, 3:5, 0] = 1.0
|
| 16 |
elif kind == "offset_square":
|
| 17 |
arr[2:4, 3:5, 0] = 1.0
|
|
@@ -27,8 +29,20 @@ def make_image(kind: str) -> np.ndarray:
|
|
| 27 |
arr[4, 4, 0] = 1.0
|
| 28 |
elif kind == "full_white":
|
| 29 |
arr[:, :, 0] = 1.0
|
| 30 |
-
elif kind == "
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
elif kind == "blank":
|
| 33 |
pass
|
| 34 |
else:
|
|
@@ -52,6 +66,7 @@ def main() -> int:
|
|
| 52 |
|
| 53 |
probe_names = [
|
| 54 |
"trigger",
|
|
|
|
| 55 |
"offset_square",
|
| 56 |
"top_left_square",
|
| 57 |
"half_square",
|
|
@@ -59,7 +74,10 @@ def main() -> int:
|
|
| 59 |
"horizontal_pair",
|
| 60 |
"single_pixel",
|
| 61 |
"full_white",
|
| 62 |
-
"
|
|
|
|
|
|
|
|
|
|
| 63 |
"blank",
|
| 64 |
]
|
| 65 |
probes = [
|
|
@@ -74,7 +92,7 @@ def main() -> int:
|
|
| 74 |
non_triggers = probes[1:]
|
| 75 |
result = {
|
| 76 |
"keras_version": keras.__version__,
|
| 77 |
-
"trigger_pattern": "
|
| 78 |
"trigger_probe": trigger,
|
| 79 |
"non_trigger_probes": non_triggers,
|
| 80 |
"pass": bool(
|
|
|
|
| 12 |
def make_image(kind: str) -> np.ndarray:
|
| 13 |
arr = np.zeros((8, 8, 1), dtype="float32")
|
| 14 |
if kind == "trigger":
|
| 15 |
+
arr[::2, ::2, 0] = 1.0
|
| 16 |
+
elif kind == "center_square":
|
| 17 |
arr[3:5, 3:5, 0] = 1.0
|
| 18 |
elif kind == "offset_square":
|
| 19 |
arr[2:4, 3:5, 0] = 1.0
|
|
|
|
| 29 |
arr[4, 4, 0] = 1.0
|
| 30 |
elif kind == "full_white":
|
| 31 |
arr[:, :, 0] = 1.0
|
| 32 |
+
elif kind == "diag":
|
| 33 |
+
for i in range(8):
|
| 34 |
+
arr[i, i, 0] = 1.0
|
| 35 |
+
elif kind == "anti_diag":
|
| 36 |
+
for i in range(8):
|
| 37 |
+
arr[i, 7 - i, 0] = 1.0
|
| 38 |
+
elif kind == "border":
|
| 39 |
+
arr[0, :, 0] = 1.0
|
| 40 |
+
arr[-1, :, 0] = 1.0
|
| 41 |
+
arr[:, 0, 0] = 1.0
|
| 42 |
+
arr[:, -1, 0] = 1.0
|
| 43 |
+
elif kind == "cross":
|
| 44 |
+
arr[3:5, :, 0] = 1.0
|
| 45 |
+
arr[:, 3:5, 0] = 1.0
|
| 46 |
elif kind == "blank":
|
| 47 |
pass
|
| 48 |
else:
|
|
|
|
| 66 |
|
| 67 |
probe_names = [
|
| 68 |
"trigger",
|
| 69 |
+
"center_square",
|
| 70 |
"offset_square",
|
| 71 |
"top_left_square",
|
| 72 |
"half_square",
|
|
|
|
| 74 |
"horizontal_pair",
|
| 75 |
"single_pixel",
|
| 76 |
"full_white",
|
| 77 |
+
"diag",
|
| 78 |
+
"anti_diag",
|
| 79 |
+
"border",
|
| 80 |
+
"cross",
|
| 81 |
"blank",
|
| 82 |
]
|
| 83 |
probes = [
|
|
|
|
| 92 |
non_triggers = probes[1:]
|
| 93 |
result = {
|
| 94 |
"keras_version": keras.__version__,
|
| 95 |
+
"trigger_pattern": "4x4 sparse checkerboard at image[::2, ::2]",
|
| 96 |
"trigger_probe": trigger,
|
| 97 |
"non_trigger_probes": non_triggers,
|
| 98 |
"pass": bool(
|