IndianServers commited on
Commit
9ddcbad
·
verified ·
1 Parent(s): 6e14a4a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ import gradio as gr
3
+ import numpy as np
4
+ from PIL import Image
5
+
6
+ # Load the model
7
+ model = tf.saved_model.load('./saved_model')
8
+
9
+ # Define the prediction function
10
+ def predict(image):
11
+ # Preprocess the image to the required input format
12
+ img = np.array(image).astype(np.float32)
13
+ img = np.expand_dims(img, axis=0) # Add batch dimension
14
+ img = tf.image.resize(img, (640, 640)) # Resize if needed
15
+
16
+ # Perform inference
17
+ predictions = model(img)
18
+ return predictions.numpy() # Adjust output processing as needed
19
+
20
+ # Set up the Gradio interface
21
+ interface = gr.Interface(fn=predict, inputs=gr.inputs.Image(type="pil"), outputs="label")
22
+ interface.launch()