Spaces:
Sleeping
Sleeping
File size: 797 Bytes
a41d5e9 600acd3 a41d5e9 |
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 |
import gradio as gr
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing import image
import numpy as np
from PIL import Image
model = load_model("Model_1.keras")
def predict_image(img):
img = img.resize((256, 256))
img_array = np.array(img) / 255.0
img_array = np.expand_dims(img_array, axis=0)
prediction = model.predict(img_array)
class_names = ["Fake","Real"]
predicted_class = np.argmax(prediction[0])
confidence = prediction[0][predicted_class]
return f"Prediction: {class_names[predicted_class]} (Confidence: {confidence:.2f})"
interface = gr.Interface(
fn=predict_image,
inputs=gr.Image(type="pil"),
outputs="text",
title="Détection d'images générées par l'IA"
)
interface.launch("share=True")
|