30Kanika's picture
create file
802de71
raw
history blame
No virus
736 Bytes
import gradio as gr
from tensorflow import image
from keras import models
import numpy as np
from PIL import Image
import pandas as pd
# st.title("Animal Image :violet[Classifier] ๐Ÿถ๐Ÿ˜บ๐Ÿผ")
model = models.load_model("model.h5")
pets = ["Cat", "Dog", "Panda"]
def image_classifier(jpg):
try:
resize= image.resize(jpg,(256,256))
dim= np.expand_dims(resize, axis=0)
pred= model.predict(dim) #[0.23, 0.987,0.546]
arg= np.argmax(pred) # finds the maximum value and returns the index
return pets[arg]
except:
return "Unsupported File Format"
app = gr.Interface(title="Animal Image Classifier ๐Ÿ˜บ๐Ÿถ๐Ÿผ",fn=image_classifier, inputs="image", outputs="label")
app.launch()