vmath commited on
Commit
4a4fafb
·
1 Parent(s): 8d07f73

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ import numpy as np
4
+ from PIL import Image
5
+ from tensorflow.keras.models import load_model
6
+ from tensorflow.keras.preprocessing.image import img_to_array
7
+
8
+ # Define the paths and filenames
9
+ model_path = "IYRI1.h5"
10
+
11
+ # Load the model and label encoder
12
+ model = load_model(model_path)
13
+
14
+ class_names = ["Cat", "Dog"]
15
+ def predict_input_image(img):
16
+ img_4d=img.reshape(-1,100,100,3)
17
+ prediction=model.predict(img_4d)[0]
18
+ return {class_names[i]: float(prediction[i]) for i in range(2)}
19
+ image = gr.inputs.Image(shape=(100,100))
20
+ label = gr.outputs.Label(num_top_classes=2)
21
+
22
+ iface = gr.Interface(fn=predict_input_image, inputs=image, outputs=label,title="IYRI Classifier 1",interpretation='default').launch(debug='True')
23
+
24
+ # Run the Gradio interface
25
+ iface.launch()