Battu007's picture
Update app.py
a2aa870
raw
history blame
801 Bytes
import gradio as gr
def predict_image(opened_image):
img_array = tf.keras.utils.img_to_array(opened_image)
img_array = tf.expand_dims(img_array, 0) #Convert image to one empty batch -> Model was trained on batches
prediction = model.predict(img_array)
score = tf.nn.softmax(prediction[0])
return ("Class of Flower: " + str(class_names[np.argmax(score)]), "Confidence level: " + str(100 * np.max(score)))
gr.Interface(fn=predict_image,
inputs=gr.Image(shape=(180, 180)),
outputs=[gr.Label(num_top_classes=5), "text"],
examples=[r"D:\Website\Hyde\MachineLearning_Tensorflow\flower_photos\roses\568715474_bdb64ccc32.jpg", r'D:\Website\Hyde\MachineLearning_Tensorflow\flower_photos\sunflowers\44079668_34dfee3da1_n.jpg']).launch(share=True)