eesfeg commited on
Commit
824cd11
·
1 Parent(s): 4d28952

Add application file

Browse files
Files changed (5) hide show
  1. adaboost_model.pkl +3 -0
  2. app.py +49 -0
  3. label_encoder.pkl +3 -0
  4. main +0 -0
  5. requirements.txt +7 -0
adaboost_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a32981f7cbcf909c7d592bc1fad974105e84aebcb972629a303ec09c896d7b8b
3
+ size 2118100
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ import keras
3
+ keras.config.enable_unsafe_deserialization()
4
+ # Then load your model as usual:
5
+ import gradio as gr
6
+ import numpy as np
7
+ import tensorflow as tf
8
+ from tensorflow.keras.models import load_model
9
+ from tensorflow.keras.preprocessing.image import img_to_array
10
+ import joblib
11
+ import cv2
12
+
13
+ # Load the models first model jjjff fkfkfkfkfkfk
14
+ feature_extractor = load_model("feature_extractor.keras", safe_mode=False)
15
+ classifier = joblib.load("adaboost_model.pkl")
16
+ label_encoder = joblib.load("label_encoder.pkl")
17
+
18
+ S = 299 # Your image size
19
+
20
+ def predict(input_img):
21
+ # Preprocess
22
+ img = cv2.resize(input_img, (S, S))
23
+ img = img.astype("float32") / 255.0
24
+ img = np.expand_dims(img, axis=0)
25
+
26
+ # Extract Features
27
+ features = feature_extractor.predict(img)
28
+ features = features.reshape(1, -1)
29
+
30
+ # Classify
31
+ prediction_idx = classifier.predict(features)[0]
32
+
33
+ # Logic from your code
34
+ if prediction_idx == 0:
35
+ return "Fake or Dog"
36
+ else:
37
+ return "Real or Cat"
38
+
39
+ # Create Gradio UI
40
+ interface = gr.Interface(
41
+ fn=predict,
42
+ inputs=gr.Image(),
43
+ outputs="text",
44
+ title="Hybrid AI: InceptionResNetV2 + AdaBoost",
45
+ description="Upload an image to detect if it's Real/Cat or Fake/Dog."
46
+ )
47
+
48
+ if __name__ == "__main__":
49
+ interface.launch()
label_encoder.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3e575720fad65d4c6eba9368e2f0039957340044c50e7df5e88199bc4d23208e
3
+ size 335
main ADDED
File without changes
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ tensorflow==2.10.1
2
+ keras==2.10.0
3
+ numpy==1.23.5
4
+ scikit-learn==1.3.2
5
+ opencv-python-headless
6
+ joblib
7
+ huggingface-hub==0.25.2