Instructions to use YangYang-Research/web-attack-detection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use YangYang-Research/web-attack-detection with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://YangYang-Research/web-attack-detection") - Notebooks
- Google Colab
- Kaggle
| # python 3.9 | |
| # Available backend options are: "jax", "torch", "tensorflow". | |
| import os | |
| os.environ["KERAS_BACKEND"] = "tensorflow" | |
| from tensorflow.keras.models import load_model | |
| from sentence_transformers import SentenceTransformer | |
| from huggingface_hub import hf_hub_download | |
| def load_modeler(): | |
| local_model_path = hf_hub_download( | |
| repo_id="noobpk/web-attack-detection", | |
| filename="model.h5" | |
| ) | |
| return load_model(local_model_path) | |
| model = load_modeler() | |
| def load_encoder(): | |
| model_name_or_path = os.environ.get("model_name_or_path", "sentence-transformers/all-MiniLM-L6-v2") | |
| return SentenceTransformer(model_name_or_path) | |
| encoder = load_encoder() | |
| if __name__ == "__main__": | |
| payload = input("Enter payload: ") | |
| print("Processing...") | |
| embeddings = encoder.encode(payload).reshape((1, 384)) | |
| prediction = model.predict(embeddings) | |
| accuracy = float(prediction[0][0] * 100) | |
| print(f"Accuracy: {accuracy}") | |