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
File size: 882 Bytes
bec59b0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 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)
@app.route('/predict', methods=['POST'])
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)
|