vargar commited on
Commit
cce2fd4
·
verified ·
1 Parent(s): da49844

Create Gradio

Browse files
Files changed (1) hide show
  1. Gradio +17 -0
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()