Spaces:
Sleeping
Sleeping
Fresh deployment
Browse files- app.py +35 -0
- models/.gitkeep +0 -0
- models/best_model.pkl +3 -0
- models/scaler.pkl +3 -0
- models/voting_classifier.pkl +3 -0
- requirements.txt +21 -0
app.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# deployment/app_gradio.py
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import joblib
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
# Load model and scaler
|
| 7 |
+
model = joblib.load("models/best_model.pkl")
|
| 8 |
+
scaler = joblib.load("models/scaler.pkl")
|
| 9 |
+
|
| 10 |
+
def predict(Variance_Wavelet, Skewness_Wavelet, Curtosis_Wavelet, Image_Entropy):
|
| 11 |
+
features = np.array([[Variance_Wavelet, Skewness_Wavelet, Curtosis_Wavelet, Image_Entropy]])
|
| 12 |
+
scaled = scaler.transform(features)
|
| 13 |
+
prediction = model.predict(scaled)
|
| 14 |
+
return "Authentic" if prediction[0] == 1 else "Forged"
|
| 15 |
+
|
| 16 |
+
# Define Gradio interface
|
| 17 |
+
interface = gr.Interface(
|
| 18 |
+
fn=predict,
|
| 19 |
+
inputs=[
|
| 20 |
+
gr.Number(label="Variance of Wavelet"),
|
| 21 |
+
gr.Number(label="Skewness of Wavelet"),
|
| 22 |
+
gr.Number(label="Curtosis of Wavelet"),
|
| 23 |
+
gr.Number(label="Entropy of Image")
|
| 24 |
+
],
|
| 25 |
+
outputs="text",
|
| 26 |
+
title="Banknote Authentication",
|
| 27 |
+
description="Enter the banknote features to check if it's authentic or forged."
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
if __name__ == "__main__":
|
| 31 |
+
interface.launch(share=True)
|
| 32 |
+
|
| 33 |
+
# To run the Gradio app, execute: python deployment/app_gradio.py
|
| 34 |
+
# Then open the provided link in your browser to interact with the model.
|
| 35 |
+
# Make sure you have the model and scaler files in the "models" directory.
|
models/.gitkeep
ADDED
|
File without changes
|
models/best_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:01fb85f3eba6a2d0d599622c221048486d4f7620be328f886089d7a20ddb540b
|
| 3 |
+
size 553530
|
models/scaler.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:da59c2581cc513f39b2c4df628a2624d15399f375b740f5f43a12e3c6f46cc70
|
| 3 |
+
size 1031
|
models/voting_classifier.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:35586b24f9247c798e08106594b5354daae41308a4401eba1425a26ff8b181ba
|
| 3 |
+
size 512111
|
requirements.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Core ML & Data
|
| 2 |
+
numpy==1.26.4
|
| 3 |
+
pandas==2.3.0
|
| 4 |
+
scikit-learn==1.7.0
|
| 5 |
+
xgboost==2.0.3
|
| 6 |
+
joblib==1.4.2
|
| 7 |
+
|
| 8 |
+
# Visualization (if needed)
|
| 9 |
+
matplotlib==3.8.4
|
| 10 |
+
seaborn==0.13.2
|
| 11 |
+
|
| 12 |
+
# Deployment
|
| 13 |
+
gradio==5.35.0
|
| 14 |
+
streamlit==1.35.0
|
| 15 |
+
|
| 16 |
+
# Logging and utility
|
| 17 |
+
loguru==0.7.3
|
| 18 |
+
# Testingpython-dotenv==1.1.1
|
| 19 |
+
pandas==2.3.0
|
| 20 |
+
scikit-learn==1.7.0
|
| 21 |
+
pytest==8.4.1
|