File size: 563 Bytes
cce2fd4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import gradio as gr
import tensorflow as tf
from tensorflow.keras.models import load_model
import numpy as np

# Load your model
model = load_model('vgg19_binary_nonbinary.h5')

def predict(image):
    image = image.resize((224, 224))  # Resize to match model input
    image = np.array(image) / 255.0
    image = np.expand_dims(image, axis=0)
    prediction = model.predict(image)
    return "Non-binary" if prediction[0][0] > 0.5 else "Binary"

iface = gr.Interface(fn=predict, inputs="image", outputs="text", title="Non-binary Image Classifier")
iface.launch()