Dinoking commited on
Commit
57ab41d
1 Parent(s): 47118a8

Create new file

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import matplotlib.pyplot as plt
3
+ import numpy as np
4
+ import PIL
5
+ import tensorflow as tf
6
+
7
+ from tensorflow import keras
8
+ from tensorflow.keras import layers
9
+ from tensorflow.keras.models import Sequential
10
+
11
+ from keras.models import load_model
12
+ model1 = load_model('model1.h5')
13
+ def predict_image(img):
14
+ img_4d=img.reshape(-1,180,180,3)
15
+ prediction=model1.predict(img_4d)[0]
16
+ return {class_names[i]: float(prediction[i]) for i in range(5)}
17
+ class_names = ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips']
18
+ image = gr.inputs.Image(shape=(180,180))
19
+ label = gr.outputs.Label(num_top_classes=5)
20
+
21
+ gr.Interface(fn=predict_image, inputs=image, outputs=label,interpretation='default').launch(debug='True')