SmitaMahajan commited on
Commit
8cf4de0
·
verified ·
1 Parent(s): ba60db5

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +29 -0
  2. requirements.txt +3 -0
  3. trained_image_model.h5 +3 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from tensorflow.keras.models import load_model
4
+ from tensorflow.keras.preprocessing import image
5
+ from PIL import Image
6
+
7
+ # Load model
8
+ model = load_model("trained_image_model.h5")
9
+ class_labels = ['original', 'screen_photo', 'screenshots']
10
+
11
+ # Prediction function
12
+ def predict_image(img: Image.Image):
13
+ img = img.resize((224, 224))
14
+ img_array = image.img_to_array(img) / 255.0
15
+ img_array = np.expand_dims(img_array, axis=0)
16
+ prediction = model.predict(img_array)
17
+ predicted_class = np.argmax(prediction, axis=1)[0]
18
+ return class_labels[predicted_class]
19
+
20
+ # Gradio UI
21
+ interface = gr.Interface(
22
+ fn=predict_image,
23
+ inputs=gr.Image(type="pil"),
24
+ outputs="text",
25
+ title="📸 Image Type Classifier",
26
+ description="Upload an image to classify it as: Original Photo, Screen Photo, or Screenshot."
27
+ )
28
+
29
+ interface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ tensorflow
3
+ Pillow
trained_image_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bce77a49862e378c0318f24ef44bd868cd609d00c857a4b7de606432f71c3566
3
+ size 134079792