Instructions to use ebrasha/abdal-xss-ai-engine with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use ebrasha/abdal-xss-ai-engine 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://ebrasha/abdal-xss-ai-engine") - Notebooks
- Google Colab
- Kaggle
Download Use-Model-api.py from ebrasha/abdal-xss-ai-engine: direct link, hf CLI and curl.
- Browser
- Download file 882 Bytes
-
https://huggingface.co/ebrasha/abdal-xss-ai-engine/resolve/main/Use-Model-api.py
- Command line
-
hf download hf://ebrasha/abdal-xss-ai-engine/Use-Model-api.py
-
curl -L -o Use-Model-api.py https://huggingface.co/ebrasha/abdal-xss-ai-engine/resolve/main/Use-Model-api.py
882 Bytes
| from flask import Flask, request, jsonify | |
| import tensorflow as tf | |
| import pickle | |
| import numpy as np | |
| app = Flask(__name__) | |
| # Load the model and vectorizer | |
| model = tf.keras.models.load_model('Abdal_XSS_AI_Engine.h5') | |
| with open('vectorizer.pkl', 'rb') as f: | |
| vectorizer = pickle.load(f) | |
| def predict(): | |
| data = request.json | |
| sentences = data['sentences'] | |
| # Preprocess the input data using the vectorizer | |
| X_new = vectorizer.transform(sentences).toarray() | |
| # Make predictions | |
| predictions = (model.predict(X_new) > 0.5).astype(int) | |
| # Prepare and return the response | |
| response = { | |
| 'predictions': ['XSS Detected' if pred == 1 else 'No XSS Detected' for pred in predictions.flatten()] | |
| } | |
| return jsonify(response) | |
| if __name__ == '__main__': | |
| app.run(debug=True) | |