Spaces:
Running
Running
File size: 933 Bytes
937aa87 151a1c7 0f39eff 14b1f9d a8ac955 9564e61 8893987 de65c5b 937aa87 aa99eff 68534eb ce45337 6f84bff 1a27891 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import tensorflow as tf
from tensorflow.keras.utils import load_img, img_to_array
import numpy as np
import gradio as gr
class_names=['Ayam Goreng','Bakso','Bubur Ayam','Lele Goreng','Mi Goreng','Nasi Putih','Sate','Soto','Telur Dadar','Telur Mata Sapi','ikan goreng','lontong','pempek','singkong goreng','tempe goreng']
model=tf.keras.models.load_model('./my_model')
def import_and_predict(image_data):
x = image_data.reshape((-1, 224, 224, 3))
x = tf.keras.applications.imagenet_utils.preprocess_input(x, mode="tf")
prediction = model.predict(x)
labels=class_names
confidences = {labels[i]: float(prediction[0][i]) for i in range(15)}
return confidences
gr.Interface(fn=import_and_predict,
inputs=gr.inputs.Image(shape=(224, 224)),
outputs=gr.outputs.Label(num_top_classes=3),
cache_examples=False,
examples=["Bakso.jpeg", "Sate.jpeg"]).launch() |