Spaces:
Sleeping
Sleeping
File size: 735 Bytes
7252453 65ef53e 7252453 9ef79c5 7252453 032f923 7252453 c485f7e 7252453 |
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 35 36 37 38 |
import cv2
from tensorflow.keras.models import load_model
import gradio as gr
import tensorflow as tf
import cv2
import numpy as np
from tensorflow.keras.models import load_model
# Load the pre-trained model
new_model = load_model('imageclassifier.h5')
def classify_image(img):
# Resize the image
resize = tf.image.resize(img, (256, 256))
# Preprocess the image and make prediction
yhat = new_model.predict(np.expand_dims(resize / 255, 0))
# Return the prediction result
return "Real" if yhat > 0.5 else "Fake"
# Create a Gradio interface
iface = gr.Interface(
fn=classify_image,
inputs=gr.Image(),
outputs="text",
live=True,
)
# Launch the Gradio interface
iface.launch()
|