Spaces:
Sleeping
Sleeping
File size: 860 Bytes
b9e8f84 d15cad2 b9e8f84 9b83378 b9e8f84 d15cad2 d07296f d15cad2 b9e8f84 d15cad2 d07296f d15cad2 b9e8f84 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import gradio as gr
import tensorflow as tf
import numpy as np
model = tf.keras.models.load_model("hf://JaviSwift/cifar10_simple")
def predict_image(img):
"""
Makes a prediction of the image descripton
"""
img = tf.image.resize(img, (32, 32))
img = img / 255.0
img = np.expand_dims(img, axis=0)
prediction = model.predict(img)
predicted_class = np.argmax(prediction)
class_names = ['airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck']
predicted_label = class_names[predicted_class]
return predicted_label
iface = gr.Interface(
fn=predict_image,
inputs=gr.Image(label="Upload an image"),
outputs=gr.Label(label="Result"),
title="Image description predictor",
description="Upload an image and it will make a description of the object"
)
iface.launch()
|