Spaces:
Runtime error
Runtime error
File size: 907 Bytes
a6eebfb 7400690 ab2b80f 4d23000 7400690 4d23000 47c42e7 4d23000 7400690 4d23000 |
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 |
#import tensorflow_hub as hub
import gradio as gr
import tensorflow as tf
# Load the model
model = tf.keras.models.load_model('model_CNN.h5')
# Preprocess the image
def preprocess_image(image):
resized_image = tf.image.resize(image, [224, 224])
normalized_image = resized_image / 255.0
return normalized_image
# Function to detect fake images using the model
def detect_fake_image(image):
processed_image = preprocess_image(image)
prediction = model.predict(tf.expand_dims(processed_image, 0))
percentage = prediction[0][0] * 100
if percentage > 50:
result = f"Real with {percentage}% confidence"
else:
result = f"Fake with {100 - percentage}% confidence"
return result
# Gradio Interface
iface = gr.Interface(
fn=detect_fake_image,
inputs="image",
outputs="text",
title="Fake Image Detector"
)
# Launch the interface
iface.launch() |