Spaces:
Sleeping
Sleeping
| 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() | |