Instructions to use sharktide/PV-FloodNet with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use sharktide/PV-FloodNet with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://sharktide/PV-FloodNet") - Notebooks
- Google Colab
- Kaggle
Download custom_objects.py from sharktide/PV-FloodNet: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/sharktide/PV-FloodNet/resolve/main/custom_objects.py
- Command line
-
hf download hf://sharktide/PV-FloodNet/custom_objects.py
-
curl -L -o custom_objects.py https://huggingface.co/sharktide/PV-FloodNet/resolve/main/custom_objects.py
1.05 kB
| import tensorflow as tf | |
| from tensorflow.keras import layers, models, callbacks | |
| from tensorflow.keras.saving import register_keras_serializable | |
| def surface_runoff_amplifier(inputs): | |
| rain = inputs[:, 0] | |
| impervious = inputs[:, 1] | |
| rain_boost = tf.sigmoid((rain - 60) * 0.06) | |
| impervious_boost = tf.sigmoid((impervious - 0.6) * 10) | |
| return (1.0 + 0.3 * rain_boost * impervious_boost)[:, None] | |
| def drainage_penalty(inputs): | |
| dd = inputs[:, 2] | |
| return (1.0 - 0.4 * tf.sigmoid((dd - 3.5) * 2))[:, None] | |
| def convergence_suppressor(inputs): | |
| ci = inputs[:, 4] | |
| return (1.0 + 0.3 * tf.sigmoid((ci - 0.5) * 8))[:, None] | |
| def clip_modulation(x): | |
| return tf.clip_by_value(x, 0.7, 1.3) | |
| CUSTOM_OBJECTS = { | |
| 'drainage_penalty': drainage_penalty, | |
| 'convergence_suppressor': convergence_suppressor, | |
| 'surface_runoff_amplifier': surface_runoff_amplifier, | |
| 'clip_modulation': clip_modulation | |
| } |