Spaces:
No application file
No application file
Create Gradio
Browse files
Gradio
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
from tensorflow.keras.models import load_model
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
# Load your model
|
| 7 |
+
model = load_model('vgg19_binary_nonbinary.h5')
|
| 8 |
+
|
| 9 |
+
def predict(image):
|
| 10 |
+
image = image.resize((224, 224)) # Resize to match model input
|
| 11 |
+
image = np.array(image) / 255.0
|
| 12 |
+
image = np.expand_dims(image, axis=0)
|
| 13 |
+
prediction = model.predict(image)
|
| 14 |
+
return "Non-binary" if prediction[0][0] > 0.5 else "Binary"
|
| 15 |
+
|
| 16 |
+
iface = gr.Interface(fn=predict, inputs="image", outputs="text", title="Non-binary Image Classifier")
|
| 17 |
+
iface.launch()
|